1
NGUI 3 Support / Tell Unity to ignore touches that happen on NGUI elements
« on: January 21, 2014, 10:23:41 AM »
Hi everyone,
I know there are some threads about this around, but I couldn't get them to work anyway as I'm not using FingerGestures.
I'm using the code found on the Unity documentation:
I modified this code to check for a collision with a ray, from the NGUI camera to any element. If the hit element is on the layer 8 (the NGUI one), don't process it, and that kinda worked. It didn't process the touches on NGUI but it also stopped processing the touches in the upper half of the screen (even when they're not on an NGUI element). Any idea what I'm doing wrong? Or any idea for a better approach? I work with the touches in different scripts, ideally I would like to write the code once and all the scripts will ignore the touches if they are on an NGUI element.
(sorry I can't paste my exact code right now).
Thanks
I know there are some threads about this around, but I couldn't get them to work anyway as I'm not using FingerGestures.
I'm using the code found on the Unity documentation:
- int fingerCount = 0;
- foreach (Touch touch in Input.touches) {
- if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
- fingerCount++;
- }
- if (fingerCount > 0)
- print("User has " + fingerCount + " finger(s) touching the screen");
I modified this code to check for a collision with a ray, from the NGUI camera to any element. If the hit element is on the layer 8 (the NGUI one), don't process it, and that kinda worked. It didn't process the touches on NGUI but it also stopped processing the touches in the upper half of the screen (even when they're not on an NGUI element). Any idea what I'm doing wrong? Or any idea for a better approach? I work with the touches in different scripts, ideally I would like to write the code once and all the scripts will ignore the touches if they are on an NGUI element.
(sorry I can't paste my exact code right now).
Thanks