Author Topic: UIPanel depth and raycast vs colliders  (Read 3201 times)

Skared Creations

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
    • Skared Creations
UIPanel depth and raycast vs colliders
« on: January 29, 2014, 05:23:14 PM »
Hi,

I'm today switching my code from 2.x to 3.x, I have an empty object with UIStretch set to Both and a collider attached with size 1x1 and it should deny to raise events on underlying elements/interface (at least it worked in 2.x by using different Z in transform). Now if I understand the new guideline I have to maintain the same Z and use "Depth" of UIPanel to bring it back/forth, it works for rendering though it also raises events on underlying elements that reside in lower depth.

Here is an example:


The mouse was where you see "X", so it's intercepting the mouse-over event of the UIImageButton under it, here is the hierarchy:
UIRoot
- Camera
---Window (Z=0, Depth=1)
----GameObject with collider and UIStretch="Both"
----...other...
---Panel underlying (Z=0, Depth=0)
----Button
----Button
----...other...

Am I doing wrong or missing something? btw I also tried to use lower Z for "Window" to try if it worked like in 2.x but it didn't affect anything.
« Last Edit: January 29, 2014, 05:41:01 PM by Skared Creations »
Skared Creations
Game Development Studio
http://skaredcreations.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel depth and raycast vs colliders
« Reply #1 on: January 29, 2014, 10:40:15 PM »
NGUI 2 used transform's scale. NGUI 3 does not, so your size 1x1 collider is 1 pixel in size. Select it, hit ALT+SHIFT+C to update its size. NGUI 3 also has an option to auto-resize the collider size (set on the widgets).