- Home /
Scripts still operate even when not active...
Hi guys and girls.
I am having real issues with this one.
I have created a simple Mouse over script which swaps textures to create a rollover effect for GUI Buttons.
The problem I am having as that this script is still working in Play mode, even though I have deactivated it in the inspector?
Has this happened to anyone else? Am I doing something wrong?
Many thanks.
$$anonymous$$ake sure it is not on two objects. You can search in the search bar of your scene hierarchy if many objects have the script buy typing the type of the script.
Afraid not old boy, The object is still funtioning as if the script were active, well the On$$anonymous$$ouseEnter function anyway.
Answer by robertbu · Jun 22, 2014 at 06:07 PM
This is how Unity works. When you deactive a script, Update(), FixedUpdate() and OnGUI() are disabled, but most if not all other callbacks still function. You can fix your problem by adding this line at the top of your OnMouseOver() callback:
if (!this.enabled) return;
That worked beautifully. Thanks for your help. Good to know for future reference.
Your answer
Follow this Question
Related Questions
Finding all GameObjects with the same tag when some of them are inactive? 4 Answers
Toggling a game object between an active and inactive state 1 Answer
How can I generate an infinite world as the player walks through it? 3 Answers
How to "touch" a slider via script? 0 Answers
After SetActive(false/true) scripts no longer update? 0 Answers