October 30, 2011 · 0 Comments
In your example code, there’s no reason for the ‘Character*’ variables not to be local (at least not that I can see). However, it can sometimes be advantageous to cache references to game objects rather than acquiring them on demand. (Sometimes though the latter is necessary, or at least preferable, and I doubt you’ll see any difference in performance either way in this case.)
As for your question, it seems the code to activate one character and disable the other two would look something like this (untested):
GameObject.Find("C1").SetActiveRecursively(true); GameObject.Find("C2").SetActiveRecursively(false); GameObject.Find("C3").SetActiveRecursively(false);
it only working for Sets the active state of this and all the game objects children to state like below.