Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Deepestblue on April 28, 2013, 03:16:48 PM
-
Hi there,
I am still in the process to get into NGUI, and after adding my first panels I saw that apparently clicking an NGUI-button doesn't only send the click event to the button but also to everything below it. In my case a button e.g. destroys a gameobject A and as the panel is right over it suddenly gameobject B right behind A gets selected with the same click. Is there a way to tell NGUI to consider this click-event "done" after a button was pressed?
Thanks for the help!
-
You either need to fully rely on an NGUI event system, or check UICamera.hoveredObject if you're relying on Input checks.
-
Thanks for the quick answer. I guess I have a little reading to do then to understand the NGUI event system completely. :)
-
Hm, I don't seem to get it. I add an onClick() function to my GameObject and "treat" the inside like I would have with an NGUI-button, but the function doesn't seem to be called. Do I have to add anything else to my GameObject to "listen" to the NGUI Event system?
Thanks!
-
You need a collider for it to receive an OnClick event.
-
Well, yes of course. It is rather that the NGUI event system doesn't seem to work for anything that's not on the NGUI layer. E.g. if I just drop
void OnHover (bool isOver) { Debug.Log (gameObject.name); }
on any GameObject on my default layer (and yes, the objects have colliders too) nothing is happening. That's why I asked if I have to do anything else to activate the NGUI event system for my clickable objects in the game world to "fully rely on the NGUI event system". Oout of obvious reasons I can't have my entire game on the NGUI layer ...
-
1. The object must have a collider.
2. The camera that sees the object must have a UICamera script on it.
3. The UICamera's event mask must have the object's layer covered.
-
Duh! I didn't know the world-camera had to have the UICamera component too! That was it. Thanks a lot for your help! :)