2D Toolkit Forum
2D Toolkit => Support => Topic started 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?
-
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.
-
You should unsubscribe from all events you subscribe to to avoid memory leaks. You generally do that with c# events to avoid leaking objects.
-
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).