Usually, I would access other `GameObjects` and their components using a construction like this:
public class SomeClass : MonoBehaviour {
public SomeOtherClass soc;
void Start() {
soc = GameObject.FindObjectWithTag("foo").GetComponent<SomeOtherClass>();
}
}
Now I've run into the situation that some game objects are not yet in then scene at the moment that `Start()` runs.
So I wondered whether I could rewrite the whole thing as such:
public class SomeClass : MonoBehaviour {
public SomeOtherClass soc {
get {
return GameObject.FindObjectWithTag("foo").GetComponent<SomeOtherClass>();
}
}
}
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 `OnGUI()` method. What would you suggest?
Thanks looks like an elegant solution (and basically, I should have been able to fid that out myself oh well). goes back to coding
– xeophin