Support => TNet 3 Support => Topic started by: mythikos on September 14, 2016, 09:39:03 PM
Title: Cant build my Unity project after receiving an ambiguous error
Post by: mythikos on September 14, 2016, 09:39:03 PM
I was working on my project and everything was working fine. Quite randomly, I started getting this error:
Assets/Scripts/Environment/Door.cs(25,28): error CS0117: `TNet.TNObject' does not contain a definition for `GetUniqueID'
Im not sure what happened but I was not even messing with my door script. The even stranger thing is the game can be run in the unity editor but I cant build it to run it standalone anymore without getting the above error. I have tried deleting TNet and re-importing it and it didnt fix anything. The code that is throwing the error:
void Awake()
{
tno = GetComponent<TNObject>();
tno.uid= TNObject.GetUniqueID();
}
Again, it was working in both the editor and standalone builds just fine and then now I am getting this error. Any idea what might be going on? I feel like it might have something to do with script execution order but I am unsure.
Edit: I am using TNet3. I am running Unity 5.3.5f1.
Title: Re: Cant build my Unity project after receiving an ambiguous error
Post by: ArenMook on September 17, 2016, 12:40:09 AM
GetUniqueID() is an internal TNObject function available only in the editor. You can go to it to see it in an #if UNITY_EDITOR define block. Why are you using it in your own custom class? It's not meant to be used externally.
Title: Re: Cant build my Unity project after receiving an ambiguous error
Post by: mythikos on September 17, 2016, 03:12:38 PM
GetUniqueID() is an internal TNObject function available only in the editor. You can go to it to see it in an #if UNITY_EDITOR define block. Why are you using it in your own custom class? It's not meant to be used externally.
That is because there are certain objects that need to be networked on the map that are not created via TNManager.Instatiate but I want them to have a unique values (and I have never been a fan of assigning values like that manually).
What would your suggestion be in this instance?
Title: Re: Cant build my Unity project after receiving an ambiguous error
Post by: mythikos on September 17, 2016, 03:40:17 PM
Alternatively, is there unforeseen harm in removing the GetUniqueID() function from the if UNITY_EDITOR block?
Title: Re: Cant build my Unity project after receiving an ambiguous error
Post by: ArenMook on September 18, 2016, 07:30:01 PM
GetUniqueID() will give you different results on different clients. It's an editor-only function, not meant for play time at all. Its sole purpose is to create unique IDs for static objects. So no, it should not come out of its editor-only block.
If you want an object to have a unique ID, then you need to either use TNManager.Instantiate (= dynamic object), or have them be present as a part of the scene from the very start (= static object).