how do i hide an complex 3dModel with its children and grandchildren?

i am trying to make a script that will show a 3dmodel (with all of its children and grandchildren ) and hide the other 2 3dmodels (with their children and grandchildren)

this is how far i have gotten, even though im not really a coder. the code works on unity primitives but not any of my complex environment models.

`var object1 : GameObject; var object2 : GameObject; var object3 : GameObject;

function Start () { = true; = false; = false;


function Update () {
   if (Input.GetKeyDown ("x")){ = true; = false; = false;
   if (Input.GetKeyDown ("z")){ = false;
 = true; = false;
       if (Input.GetKeyDown ("c")){ = false;
 = false; = true;

Hello, I have encountered the same problem when I had to enable a FPS controller and then disable it and all its children's to enable a third person controller.

first you could use: = false; // (or = true to enable)

but you would need to do that for all the "pieces of the object".

the second alternative would be using:

Object.SetActiveRecursively(true); // (or false to disable)

that would make the code simpler and smaller as well. I made a post in my recently made blog about this.

Blog's Link

Hope it helps :)