2D Toolkit Forum

2D Toolkit => Support => Topic started by: kag359six on July 18, 2013, 07:24:56 pm

Title: OnDown event not triggering
Post by: kag359six on July 18, 2013, 07:24:56 pm
I have a collider with a tk2dUIItem attached to it. I set the GameObject to send the message to, and in the script of that GameObject I added the  method "onReset" to OnDown inside "void Start()". Why isn't the onReset method being triggered when i click on the UIItem?
Title: Re: OnDown event not triggering
Post by: kag359six on July 18, 2013, 08:03:09 pm
Ok I figured out why it's not working. I was missing the OnEnable and OnDisable methods. Why are these necessary? I haven't seen these referenced in any C# events tutorial, or as a method inside Unity.
Title: Re: OnDown event not triggering
Post by: unikronsoftware on July 18, 2013, 08:20:55 pm
You should unsubscribe from all events you subscribe to to avoid memory leaks. You generally do that with c# events to avoid leaking objects.
Title: Re: OnDown event not triggering
Post by: profanicus on July 19, 2013, 01:48:20 am
Ok I figured out why it's not working. I was missing the OnEnable and OnDisable methods. Why are these necessary? I haven't seen these referenced in any C# events tutorial, or as a method inside Unity.

They are referenced in the Unity docs, check out the list of Monobehaviours here (http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.html).