- Home /
Disabling a script in runtime
Hello,
Is there any way to disable a script (MouseLook in this case) in another script (my GUIhandler)? I have currently solved this by making a bool in my GUIhandler. The MouseLook script then checks if this bool is true, to use MouseLook. I would like to be able to do this by just disabling the MouseLook script, in my GUIhandler.
Thanks!
Answer by almo · Jun 01, 2011 at 02:53 PM
If the script is a Mono Behaviour, then you can do this:
http://unity3d.com/support/documentation/ScriptReference/Behaviour-enabled.html
This only appears to be working on 1 instance of the script. GetComponents (the plural) does not have the enabled function...
GetComponents returns a list of components. You would then have to loop through them and shut them off one by one.