Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: benb on August 14, 2013, 06:31:11 PM

Title: Nested Panels and Depth
Post by: benb on August 14, 2013, 06:31:11 PM
I've encountered what seems like unexpected behavior with some nested panels. I'm doing this so I can have a scrolling area. What I have is in the parent panel a couple of labels and a sprite as a background. Then, the child panel has a bunch of labels in it. Both panels use the same atlas, but no matter what I do with the Z position or depth, the labels in the child panel are always behind the background sprite. However, if I put something like a button in the child panel, then everything ends up in front of the background sprite without having to do anything to the Z or depth. Here are a couple screenshots of what I'm talking about:
(http://benbarefield.com/Content/result.png)  (http://benbarefield.com/Content/heirarchy.png)
Any idea what might be causing this?
Title: Re: Nested Panels and Depth
Post by: ArenMook on August 15, 2013, 07:10:00 AM
Most common cause -- Z offset in one of the nodes leading up to your panel.

Different panels = different draw calls, so only Z will affect order, not depth.
Title: Re: Nested Panels and Depth
Post by: benb on August 15, 2013, 07:32:46 PM
Thanks for the reply! All the objects in the scene are at z = 0. Additionally, that wouldn't explain why just adding a button to the child panel would bring everything in front of the background sprite.
Title: Re: Nested Panels and Depth
Post by: ArenMook on August 16, 2013, 12:19:39 AM
It does, actually. Adding another widget changes the "center" of the generated geometry, altering the distance to the camera. Tilt your scene view camera and look at your UI sideways.
Title: Re: Nested Panels and Depth
Post by: benb on August 16, 2013, 01:03:27 AM
Alright, after tilting the camera, it does look like everything is slightly closer when the button is in the scene. However, no I feel like I'm going insane, because after setting the panel to z = -1, the layering problems are going away. I could have sworn I did that before. Oh well, thanks for the help.
Title: Re: Nested Panels and Depth
Post by: benb on September 05, 2013, 10:23:18 PM
This has come up again! But only in the inspector. When I'm editing the scene, the contents of the nested panel are behind stuff in the parent panel, even when the nested panel has z = -1. As soon as I enter game mode, the draw order figures itself out, and the nested panel's contents are shown in front of the parent panel's contents. Thoughts?

I just noticed that it seems to matter where in the viewport the UI components are - see attachments (the only difference is the viewport, I haven't changed any of the values on the components).
Title: Re: Nested Panels and Depth
Post by: ArenMook on September 07, 2013, 12:59:02 AM
Your scene view is not in an orthographic mode. It's in perspective mode. Scene view follows the same rules as an in-game camera.

Click the square in the top right.
Title: Re: Nested Panels and Depth
Post by: benb on September 08, 2013, 11:09:50 PM
Wow. Thanks. Hate missing something so small.