- Home /
Disabling THIS script from code
Hi! My problem is I'm going to disable script from his code. It's easy to make. But I've got 2 same script in 1 gameObject. When I use this:
gameObject.GetComponent<StartPosition>().enabled = false;
I disable second script. So i tried this:
gameObject.GetComponent<this>().enabled = false;
But it isn't working (compile fails). Have you got any other ideas to disable script?
Answer by Eric5h5 · May 21, 2014 at 04:29 PM
enabled = false;
That's it.
You can also get rid of the "gameObject." part of "gameObject.GetComponent" stuff and just use "GetComponent".
Oh yeah... It's normal that I use very difficult code when it's not necessary XD. Big thx for you for good answer and useful suggestion.
Your answer
Follow this Question
Related Questions
Enabling/Disabling Multiple Tagged objects 1 Answer
Information about Behaviour.enabled 1 Answer
Disalbe/Activate script if a key is pressed. 1 Answer
disable a script when a object is hidden? 1 Answer
A do nothing script? 2 Answers