Hi there!
I’m pretty new to Unity (few months) and I’ve been mostly just hacking my project together to try to get it to an MVP status.
When I started my project, i just started spawning everything in the editor and referencing them in script through builtin arrays. Now, I went to clean up some stuff and I started running into all sorts of issues. This started because I changed how I was instantiating/referencing objects from script to now I instantiate the objects on startup vs. in the editor.
Basically, if my objects have iTween.Init(this.gameObject) inside of the Start() functions, I get a ton of the following problems when calling Instantiate on them:
- My console starts telling me that a lot of objects have NullReferenceExceptions in the RetrieveArgs().
- After that, it just spews a series of LateUpdate() and TwenUpdate() errors since the id of the object was null in the RetrieveArgs() iTween call… not sure why since the object is valid…
So, I remedied that a little by shoving the iTween.Init call inside of an Initialize function in every object that I want to use. However, during run time, when I go to Destroy/Instantiate another object, I get problems…
My questions are as follows:
- Should I just go back and keep things using builtin arrays and not do any instantiating/creation during run time? Although before was more efficient, I’m just trying to know what it’s considered as “clean” by Unity standards…
- Should objects that use iTween be mutually exclusive to objects that are created by using the Instantiate() method?
- Could someone perhaps provide me an answer about what’s going on behind the scenes with iTween and the Instantiate() method?
Cheers!