I'm trying to setup a simple hide and unhide gameobject in Unity, but can't seem to get my coding to work correctly. What wrong with what I have written so far.
#pragma strict
public var myObject :GameObject;
if (GUI.Button(new Rect(1120,930,100,50),"3D MODEL"))
{
gameObject.SetActive(true);
}
}
There you go, this should solve your problem. http://answers.unity3d.com/questions/7776/how-to-make-an-gameobject-invisible-and-disappeare.html Good luck.
You can turn off the rendering of a GameObject by disabling its MeshRenderer component, e.g.
GetComponent(MeshRenderer).enabled = false;
You can disable a GameObject entirely by making it inactive, e.g.
gameObject.active = false;