Author Topic: Adjusting depth does nothing! Why?  (Read 14447 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Adjusting depth does nothing! Why?
« on: October 01, 2012, 04:55:59 PM »
Since it's obvious that people don't read the FAQ, I've decided to make a separate sticky since this question gets asked every.single.day.

Quote
Adjusting Depth on one widget doesn't seem to move it forward in front of another! Why?
"Depth" property is used to determine the drawing order of the widgets within the same panel that use the same atlas. If you are using different atlases or labels using a dynamic font, bring the widgets forward on the transform's Z, moving them closer to the camera (-Z). If you are using different panels, adjust the transform of the panel you want to bring in front to a lower negative Z value (-Z). I highly recommend sticking to one atlas if you can manage it, it will make your life significantly easier.

Technical Explanation:

Normally Unity sorts everything by transform's Z coordinate. Objects closer to the camera (lower Z value) will cover objects that are farther away (higher Z value). This works fine when the UI is perfectly flat and is using an orthographic camera (read: it's a 2D UI). For 3D UIs, however, turning the window even slightly completely changes the distance to the widgets, and makes this approach completely unsuitable. This is why "Depth" was invented: it's a fixed value that stays constant, regardless of the transform. Unfortunately there is no way to make different draw calls respect this value (different panel / atlas = different draw call), so with multiple atlases or panels, Z still needs to be used.

More info: http://www.tasharen.com/forum/index.php?topic=767.0
« Last Edit: May 10, 2013, 12:16:35 AM by ArenMook »

Vr

  • Guest
Re: Adjusting depth does nothing! Why?
« Reply #1 on: May 21, 2013, 10:48:28 AM »
I also have a problem with multiple atlases and adjusting depth. Reasons it completely clear to me. But still if I want to draw set of widgets 1 with material A, set of widgets 2 with material B and widgets 3 with material A again with explicitly creating 3 separate draw calls. Can I make it on Unity? I already tried to do so with the NGUI (change the order of drawing the widgets in Fill method in UIPanel class), but i failed. Rendering work, but its order was the same. As if Unity group geometry with the same materials and draw batches. I was doing what I need on my engine (in pure opengl), but not sure whether i can do something like that on Unity. Is it possible to do what I need on Unity and what are the ways to do this with NGUI? Thanks in advance and sorry my poor English.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Adjusting depth does nothing! Why?
« Reply #2 on: May 21, 2013, 12:33:49 PM »
Panel 1 - Widgets 1 (A) & 2 (B)
Panel 2 - Widgets 3 (A)

freeglass

  • Guest
Re: Adjusting depth does nothing! Why?
« Reply #3 on: June 08, 2013, 12:14:39 AM »
NGUI Depth Manager you requested issues can be fixed by using.

This program is a tool designed to help solve problems that occur while using NGUI Widgets Depth .

NGUI Depth Manager in AssetStore