- Home /
Question by
leoeparce · Oct 08, 2016 at 05:01 AM ·
button trigger events
Make an object disappear?
How do I make a door disappear when a button is pressed? I cant figure it out.
Thanks in advance,
Leo
Comment
Answer by tanoshimi · Oct 08, 2016 at 06:47 AM
You disable its renderer:
GetComponent<Renderer>.enabled = false;
And please search first before asking new questions - this is very common:
Answer by Lilius · Oct 08, 2016 at 07:01 AM
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 ()
{
door.SetActive(false);
}
I have a feeling that this might not be what you wanted, but it is a button that hides a door.