- Home /
How to disable an object
Hi, I have a little problem. I have an object, with an attached script, this object has a public variable where I introduce a object in the unity editor. Now I want a function on my script to enable or disable this object on game. There is a function for it? Lot of thanks
Answer by Mortennobel · May 22, 2011 at 10:50 AM
GameObjects can be enable/disabled using the active attribute.
Scripts (and other Behavior objects) can be enabled/disabled using the enabled attribute.
To disable children, you need to iterate the transform or iterate the child-components and disable the Behavior objects or GameObjects needed.
Thanks, and what can I do enable/disable the object with his childs?
Your answer
Follow this Question
Related Questions
Disable script on other object 2 Answers
Enable/Disable GameObject Button script 1 Answer
How to draw GUI Text from code 1 Answer
How can I tell what prefabs a child object (script) is in? 2 Answers
Object Multiplier Script and button 1 Answer