Hello Guest

Author Topic: Cant register event listeners  (Read 3550 times)

calebheale

  • Newbie
  • *
  • Posts: 2
    • View Profile
Cant register event listeners
« on: July 16, 2014, 12:03:47 am »
I have a tk2dUIUpDownButton script as a component on a game object that I would like to use as a button.
I have a second script to write my event handlers also as a component on the same game object
I am trying to access the uiItem to reference the events
In OnEnable for my custom script I am trying to access uiItem using the following:
tk2dUIItem ui = GetComponent<tk2dUIUpDownButton>().uiItem;

I get a null reference exception when trying to register my event handlers.

What am I doing wrong?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Cant register event listeners
« Reply #1 on: July 16, 2014, 09:35:52 am »
tk2dUIUpDownButton needs a UIItem to work. I suggest looking at the ui demo prefabs to see how they're wired up, or just base your design off one of the prefabs.

calebheale

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Cant register event listeners
« Reply #2 on: July 16, 2014, 02:56:46 pm »
Thank you. That is exactly what I was missing. And yes, looking at the prefabs helped make a lot more sense of it.