|
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
(comments are locked)
|
|
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. For example: Thanks looks like an elegant solution (and basically, I should have been able to fid that out myself oh well). goes back to coding
Nov 15 at 04:58 PM
xeophin
(comments are locked)
|
Unity Answers has moved to a new system, and some users may have trouble logging in.