UI Root # panel.depth = 0
Camera
Panel # height = 800
Bg Collider # a full screen collider
Clip Panel # panel.depth = 1, size 300x300
Button
In a simple 2d UI setup as above, I put a full screen "Bg Collider" at the bottom and a small "Clip Panel" with a "Button" inside on the top. Kind like a trivial modal dialog. If I click the button, it will response me. If I click the rest part of the screen, the "Bg Collider" will capture the event to avoid it pass to any widgets behind the panel. Now the tricky thing is that if I changed transform.localPosition.y of "Clip Panel" to any number bigger than 150, say 160, the button will no longer receive the event.
Digging into NGUI source code, I found that in UICamera.Raycast(Vector3 inPos), mHits will be [Button,Bg Collider], but later IsVisible(lastWorldPosition, Button)) return false. But it shouldn't.
If change the "Clip Panel" to no clipping, then it works again.
Is this a bug? or I shouldn't move a clipping panel by change it's transform?
Please check out the test project at
https://bitbucket.org/favoyang/2dhitordertest (you need import NGUI 3.6.5)