Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: danilofaria on April 24, 2016, 12:50:36 PM

Title: How to stop event from propagating?
Post by: danilofaria on April 24, 2016, 12:50:36 PM
I've been having a problem with NGUI.

If I touch a button in the UI and there is some game object right underneath it, then it also receives the event (more specifically OnMouseDown in my case).

This looks really bad and I don't want the objects to receive this event if the UI has received the even first.

What can I do about this?

Thanks!
Danilo
Title: Re: How to stop event from propagating?
Post by: ArenMook on April 25, 2016, 12:53:45 PM
OnMouseDown is a Unity event. It's not an NGUI event, which is why NGUI can't do anything about it.

You should be using OnPress (bool isPressed) instead.
Title: Re: How to stop event from propagating?
Post by: danilofaria on April 25, 2016, 06:49:01 PM
I added the OnPress (bool isPressed) method to my game object script but nothing happens. It doesn't get triggered.
What other steps do I need to take?
Title: Re: How to stop event from propagating?
Post by: ArenMook on April 25, 2016, 10:34:41 PM
You need to make sure that the camera that draws this game object has UICamera script attached.
Title: Re: How to stop event from propagating?
Post by: danilofaria on April 26, 2016, 10:51:04 PM
It works! Thanks!