Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: benblo on September 30, 2013, 10:13:10 AM

Title: Understanding depth in 3.0
Post by: benblo on September 30, 2013, 10:13:10 AM
I'm struggling to understand the new depth system, unfortunately the upgrade guide in the release notes does not tell much on the subject. How exactly did it work before? how does it work now? Can someone point me to docs/topic?

We're using little drops on NGUI inside a rather big menu scene (orthographic), with various layers, doors opening (regular meshes), etc.
In 2.7 is was very fine, the GUI was treated like any other mesh, we could just layer it as we pleased. In 3.0, I just want to gouge out my own eyes in frustration. It all seems totally random: sometimes things are on top, sometimes behind, it works once out of two and then not at all...
The scene starts with some doors closed, some GUI behind, when I open the doors the GUI shows up fine (I can tell the depth is OK because the doors overlap progressively during their "appear" anim), then some more text shows up... and when I close the doors ALL the text is now above! what the hell...
Even in edit mode the behavior is un-understandable: I've tried tweaking the depth of each element until they were behind the doors, but then I change another element and boom, all the ones I tweaked before are now in front again... dammit!!!

I honestly don't care at all about draw calls (you should see our setup it's so generous it's ridiculous, it's not the 3 draw calls that NGUI is gonna save me that matter), and all this batching is making it very hard to understand what's going on.
Title: Re: Understanding depth in 3.0
Post by: ArenMook on September 30, 2013, 11:31:12 AM
In 3.0 the order depends solely on depth of widgets. This means that if you have 2 widgets, one with depth of 0, and another with depth of 1, the widget with the depth of 1 will always be on top of the widget with the depth of 0, regardless of which panel they are on.

It's that simple.

If you want to bring something to front via code, use NGUITools.BringForward. In the editor the same can be achieved by selecting it (generally a window you want to bring to front) and hitting ALT+SHIFT+= (or NGUI menu -> Selection -> Bring to Front).

If you have depth conflicts, which widget will appear in front is undefined.
Title: Re: Understanding depth in 3.0
Post by: benblo on October 01, 2013, 08:50:26 AM
Yeah but... how will they be sorted relative to non-NGUI geometry (traditional meshes)? What will the actual z of the resulting geometry be? How do I split the UI in 2 (some above the normal geometry, some below)? This is what I absolutely don't get.

Last night after banging on my scene for hours I managed to have it work the way I wanted (I honestly couldn't tell you how), and today I've added more labels... boom, all is lost again.
Title: Re: Understanding depth in 3.0
Post by: Nicki on October 01, 2013, 02:24:20 PM
You'll have to use multiple cameras, so you have some in a backgrond layer and other in a forground layer.

The camera depth supercedes the widget depths.