Hello Guest

Author Topic: OnDown event not triggering  (Read 4989 times)

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
OnDown event not triggering
« 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?

kag359six

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: OnDown event not triggering
« Reply #1 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: OnDown event not triggering
« Reply #2 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.

profanicus

  • 2D Toolkit
  • Full Member
  • *
  • Posts: 167
    • View Profile
Re: OnDown event not triggering
« Reply #3 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.