Author Topic: Nested Panels and Depth  (Read 3230 times)

benb

  • Guest
Nested Panels and Depth
« 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:
 
Any idea what might be causing this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Nested Panels and Depth
« Reply #1 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.

benb

  • Guest
Re: Nested Panels and Depth
« Reply #2 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Nested Panels and Depth
« Reply #3 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.

benb

  • Guest
Re: Nested Panels and Depth
« Reply #4 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.

benb

  • Guest
Re: Nested Panels and Depth
« Reply #5 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).
« Last Edit: September 05, 2013, 11:23:05 PM by benb »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Nested Panels and Depth
« Reply #6 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.

benb

  • Guest
Re: Nested Panels and Depth
« Reply #7 on: September 08, 2013, 11:09:50 PM »
Wow. Thanks. Hate missing something so small.