Author Topic: Event listener not doing anything...  (Read 1994 times)

Rafe

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Event listener not doing anything...
« on: July 22, 2012, 04:23:21 AM »
Hi,

I think I am setting this up correctly:

  1.    
  2.     // In the class
  3.     public UIImageButton playButton;        
  4.  
  5.     // in Start()
  6.     UIEventListener.Get(this.playButton.gameObject).onClick += this.OnPlay;
  7.  
  8.     // My func definition
  9.     public void OnPlay(GameObject obj)
  10.     {
  11.         Debug.Log("OnPlay");
  12.     }
  13.    

  • The log message never plays and there are no error messages.
  • I attached a test script and the button IS getting an OnClick event
  • When I play the game no UIEventListener component is added to the gameObject. I tried adding one manually and it didn't have any effect.

Any thoughts?

Rafe

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: Event listener not doing anything...
« Reply #1 on: July 22, 2012, 06:01:37 AM »
Well it works. There was null reference exception (needed to drag&drop an unrelated reference used in the same script) that was quietly breaking this. Once I fixed it the tap started flowing again!