The question is answered, right answer was accepted
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 :)
Answer by UsmanAbbasi · May 11, 2016 at 06:14 AM
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.
Thank you, that is eye-opening for me. I guess I will have to manually add a flag to the object. Thanks again.
You are welcome. If it helped. $$anonymous$$ark my answer as "Answered" which helps other users find it.
Follow this Question
Related Questions
Move object in Scene view using mouse delta 0 Answers
How works EventTriggerType.Move ? 2 Answers
Unity 3d - Change texture by clicking 0 Answers
How Can I Create My Own Textures? 3 Answers
Texture/Material changes but is not reflected in the game world 0 Answers