PowenKo, Unity Tutorial 140 , GameObject, Hide/Show a game object and activate/deactivate.

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.

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Unity3D4

Amazon

adsbygoogle

Recent Posts

Categories

Amazon