Disabling script with OnMouseUp, dynamically.

Hello there.

I have a gameObject called “Hotspot”. The gameObject has a script component called “ShowEmptyHotspotData”. This component uses the “OnMouseUp” method to pop up some UI.

Once some work is done, I am disabling this component from script, by calling : MSelectedHotspot.GetComponent ().enabled = false;

This successfully disables the component, I can see in the editor that the tick-box next to it is un-ticked.

The problem is, the component still reacts to OnMouseUp calls and pops up the UI. Why does that happen?

Thanks :slight_smile:

Disabling a script means that its LifeCycle methods will no longer be called i.e. “Update(), LateUpdate(),etc”. Script will still work on the object. Try making a script without any lifecycle methods. Remove “Start(), Update(), etc” from the script and attach it to a game object, that will show you the script without the tick-box which will help you understand the concept.