- Home /
How is click/touch input handled when using different layers?
Unity n00b here, just getting through the basics right now. I'm using NGUI to get my UI to render on top of a few 3D objects. I currently have two camera objects in my scene --- one that renders the 3D objects in the scene (cull mask set to "Default" layer, not "Everything"), and then the camera provided by NGUI.
I've put the NGUI root in a custom-declared "NGUI Layer" that I made. I applied this recursively so it also put the NGUI camera in this layer.
I made the standard camera object not include "Everything" but instead "Default".
Rendering-wise everything looks good, but I cannot click on the NGUI widgets, or detect hover events. It clicks fine if I keep everything in the same layer (but the rendering isn't how I'd like). I figure this must be a layer-related issue. Can someone explain to me how the basics of the layer-input relationship in Unity?
Thanks!!
Answer by gregzo · Apr 02, 2012 at 08:36 AM
From a post by NGUI's author on Unity forums, replying to a similar problem :
Edit -> Project Settings -> Physics, check "Raycast Hit Triggers".
This did not work for me. I found "Raycast Hit Triggers" to be set already. I tried un-checking "Ignore Raycast" in the Layer Collision $$anonymous$$atrix in the "NGUI Layer" column, and that didn't seem to fix the fact that I can't click on anything. Any other ideas?
Answer by jasonFHH · Apr 03, 2012 at 11:12 PM
I got a solution from ArenMook (NGUI creator) that seems to work. Click on NGUI's camera object, then in the script component for UICamera, change the Event Receiver Mask to match whichever layer you have your NGUI widgets on. That should make sure the right clicks/input is being received. Seems to work for me! More details here ---> http://forum.unity3d.com/threads/114833-NGUI-%28Next-Gen-UI%29-demo-amp-final-feedback-request?p=880566&viewfull=1#post880566
Answer by icetear · Jan 31, 2013 at 03:21 PM
You have to make sure that in your UICamera the "Event Receiver Mask" ist set to the correct layer.
Your answer
Follow this Question
Related Questions
Input behind 3d 2 Answers
NGUI KeyBinding Reversal? 0 Answers
NGUI with Leap Motion, or NGUI without mouse 2 Answers
Disable game logic related input when touching NGUI objects 1 Answer