Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: bagomints on January 19, 2014, 10:40:04 PM
-
Here's the process:
-I'm instantiating a child to add to an invisible widget acting as a container for the child objects I instantiate using NGUITools.AddChild(..);
-Child object :depth 3
--Container1 :depth 3
---Slider A : depth 3
---- Slider A background : depth 3
---- Slider A foreground : depth 4
---- Slider A Label : depth 3
---Slider B: depth 3
---- Slider B background : depth 3
---- Slider B foreground : depth 4
---- Slider B Label1 : depth 3
---- Slider B Label2 : depth 3
---Slider C : depth 3
---- Slider C background : depth 3
---- Slider C foreground : depth 4
---- Slider C Labe1l : depth 3
---- Slider C Label2 : depth 3
-- Container2 : depth 3
--- Label1 : depth 3
--- Label2 : depth 3
-- Sprite : depth 3
So the child object has 2 containers, 1 for sliders, 1 for some labels, and a separate Sprite.
Everything is depth 3, since they don't overlap each other, except the UISlider foreground sprites because they sit ontop the slider's background sprites are depth 4.
When I open the DrawCalls from the UIPanel, everything is being rendered almost separately, one at a time or sometimes 2 at once.. doesn't make sense to me seeing as they ALL share the same atlas, and all the Labels share the same material.
-
You shouldn't use the same depth values on both parents and children. That's confusing, and makes it uncertain what will get the events. When things overlap, they should have different depth values.
-
The parents are just invisible widgets though, just containers, and nothing overlaps visually. But I'm going to try to change the parents depth values and see and post results.
-
Note what I said there:
http://www.tasharen.com/forum/index.php?topic=7643.msg36195#msg36195
Depth is not cumulative.
-
Do I understand properly that even if, for example, 2 UISliders do not overlap, but are under different parents, giving them the same depth value is still confusing?
Should I literally just change to unique depth values for every single widget I'm using?
-
Okay I managed to go from 20 drawcalls to 2 drawcalls separating depths of all widgets.
Each parent has a different depth value, but the child sprites share the same depths like so:
Slider 1 - depth 4
Slider 2 - depth 5
Slider 3 - depth 6
Label container - depth 7
but all 6 background and foreground sprites that the Sliders share are same depth values (8 and 9)
and all Labels share the same depth (3)
So as you can see every parent has a different depth value, and each shared sprite or label have the same depth value.
Now they all render in 2 drawcalls (sprites from same atlas + font from same material separately)
Thank you :)