Make an object disappear?

How do I make a door disappear when a button is pressed? I cant figure it out.

Thanks in advance,


You disable its renderer:

GetComponent<Renderer>.enabled = false;

And please search first before asking new questions - this is very common:

With UI button, attach a script to game object in hierarchy and drag that object to button component, there is a place for game object. Then select the function in the drop down menu of the button component (No Function is selected as default). You could disable the door in the script:


public GameObject door;

void Disappear ()


I have a feeling that this might not be what you wanted, but it is a button that hides a door.