Author Topic: Single event capture object  (Read 3201 times)

Twiitch

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Single event capture object
« on: January 24, 2013, 06:13:29 AM »
Hi,

I'm new to NGUI (pro), so hopefully this is a simple question to answer.

If I have a bunch of buttons hanging off a UIPanel, there appears to be only two ways of wiring up events to recognise the OnClick() event:

1. Manually wire up the event with a UIEventListener like this: UIEventListener.Get(myButton.gameObject).onClick += _onClick;
2. Create a separate MonoBehavior for each button with the OnClick method handled, explained here: http://www.tasharen.com/?page_id=160

Is there any way of providing a GameObject as a target for all events? So I could just point all buttons at my GameObject and attach something like a UIEventHandler behavior with a OnClick(GameObject go) ?

I'd like to know the best way to do this before getting too deep into our UI.

Cheers,
Shane

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Single event capture object
« Reply #1 on: January 24, 2013, 09:52:32 AM »
NGUI Pro is a separate product. Unless you have access to the repository, you're using NGUI Standard. :)

UIButtonMessage is what you're looking for.

Twiitch

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Single event capture object
« Reply #2 on: January 24, 2013, 07:30:44 PM »
Ah, my bad! We've purchased the non-pro version, so I think we'll upgrade :)

I've just implemented the "UIButtonMessage" component and it works exactly as I wanted. Thanks! :)

Cheers,
Shane