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.

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;