- Home /
c# How Do I disable current script or anyother script in the program within code?
say I have 3 scripts called ,BOB,ABE,GUY
In script BOB, I want to enable ABE, and disable GUY... how could this be done in unity, using c#?
thank you.
Answer by allenallenallen · Dec 23, 2015 at 04:14 AM
There are many similar questions already:
http://answers.unity3d.com/questions/548362/enabledisable-script-from-another-script-c.html http://answers.unity3d.com/questions/673680/how-can-i-enable-and-disable-scripts-at-runtime.html
Answer by G4merSylver · Dec 23, 2015 at 01:21 PM
As allen said, there are already many questions for that. Try using OnEnable and the setactive attribute, perhaps OnValidate would work to. Note that setactive also should work with getcomponent. Or was it awake... Just try those three, one should work I am not sure which one. (Awake, OnEnable, OnValidate).