Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: vexe on September 03, 2013, 09:42:49 AM

Title: [SOLVED] Widget still responds to events, even though its script is disabled!
Post by: vexe on September 03, 2013, 09:42:49 AM
Hello, I have a script called TextFile, that I only want to enable once I pickup the text file game object, it has a lot of stuff that I must set AFTER I pick it up. Some of those stuff are accessed in events such as OnHover, so if I hover over the gameobject with the TextFile BEFORE picking it up I get en exception, things are not set yet. So all I should do, is disable the script at first, and when I pick it up (which is done from another FilePickupScript attached to the game object as well) I enable the TextFile and assign the missing stuff.

But the problem is, even though I disabled the TextFile script, its events still got triggered! (OnHover got called!)

What is going on? why is this happening?
Title: Re: Widget still responds to events, even though its script is disabled!
Post by: ArenMook on September 04, 2013, 04:41:14 AM
Intentional. Unity sends messages to all scripts, even disabled ones. Do a simple "if (!enabled) return;" at the top of your OnHover function.
Title: Re: Widget still responds to events, even though its script is disabled!
Post by: vexe on September 04, 2013, 04:42:54 AM
EVIL Unity, good Aren, happy me ^_^