Usually, I would access other
Now I've run into the situation that some game objects are not yet in then scene at the moment that
So I wondered whether I could rewrite the whole thing as such:
The question of course is whether this will affect performance; even more so when several of those properties are chained and are called from within an
asked Nov 15, 2010 at 04:30 PM
It would affect performance, proportional to how many times that function is being called. However, there's a happy middle ground which might fit your situation, which is to use a private variable to store the result, and only do the "Find" if the private variable hasn't yet been populated.
You could also use this opportunity to check whether the "foo" gameobject exists yet, and therefore avoid throwing a null reference error.
answered Nov 15, 2010 at 04:42 PM