Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Twiitch on January 24, 2013, 06:13:29 AM

Title: Single event capture object
Post by: Twiitch 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
Title: Re: Single event capture object
Post by: ArenMook 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.
Title: Re: Single event capture object
Post by: Twiitch 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