Hi all,
-
I have this fear that my coroutines will not stop
so I use a return break in all coroutines and then use StopCoroutine again in onDisable (or elsewhere depending on context ). Is this useful or does it give ‘hidden’ problems? And if a coroutine is ran and the gameobject is disabled, does the coroutine stop of does it run until the break? -
I have several scripts that undo their changes in OnDisable. Things like StopCoroutine and for loops (to for example reset material colors). Now when I stop the editor I get errors that the GameObject is not available anymore and that I should do an null check. Does this give problems in the final application or can I ignore this?
-
I read not to use SendMessage too much, so I don’t alternatively I use GetComponent. But when I load a script component in a variable, that variable is a reference to the script(on that gameobject) right? Or it stores the entire script? And if its a reference then why not always use the ‘getcomponent message’? And whats the difference between SendMessage besides specifically pointing to the right method in the right component?
-
When possible I try to use things like GameObject.Find(“something”).GetComponent to avoid creating extra member variables. Whenever I don’t need them much, for example for toggling things in a tutorial. As a tutorial is only used once or twice. Is this good practice? And do the class member variables still use memory if the Gameobject is deactivated?
btw I use C#.
Thanks in advance!