Author Topic: NGUI - Modular UI - World Z problem - Childrens' Z increases strangely (BUG?)  (Read 2692 times)

vexe

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 153
    • View Profile
Hello guys,

I saw the NGUI modular UI video and I decided to make my UIs modular as well.

The positioning and resizing/stretching worked very well. But there's something not right when I resize the original main background, the childrens' Z depth increases! I have no idea why.

I have made a video for it, please have a look http://www.youtube.com/watch?v=CwlzzSPZXxU&feature=youtu.be

I'm using 3.0.4

Here's my setup:

  1. (Panel) - ItemBox
  2. - Main Window (Empty game object)
  3. --- Background - Outer (this is the background that I resize, and with it everything resizes)
  4. --- Glow - Outer (Has a UIAnchor and UIStretch (both) with "Background - Outer" as a container)
  5. --- Content Window
  6. ----- ItemBox (has an ItemBox script)
  7. ------- Items Window (Empty GO)
  8. ---------- Background - Inner (Has a UIAnchor and UIStretch (both) with "Background - Outer" as a container)
  9. ---------- Glow - Inner (Has a UIAnchor and UIStretch (both) with "Background - Inner" as a container)
  10. ------- (Panel) - Clipping (Has a UIAnchor and UIStretch (both) with "Background - Inner" as a container)
  11. ---------- Items (Empty GO)
  12. --- Title Bar
  13. ----- Background (Has a UIAnchor and UIStretch (horizontal) with "Background - Outer" as a container)
  14. ----- Buttons (Empty GO)
  15. ------- Close (Has a UIButton UIAnchor with "Background" (the previous one) as a container)
  16. ------- Sort  (Same)
  17.  

NGUI 3.0 is really awesome, but still there are some things I'm failing to do well, maybe it's just me.

Thanks a lot for your help.

« Last Edit: November 09, 2013, 10:11:05 AM by vexe »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
That's unusual, but likely related to floating-point precision. I'd suggest playing with the code inside UIAnchor, on lines 215 and 232. I'd also suggest making sure that your UI has no XY rotation on any of the elements (Z rotation is fine), and that Z position on all elements is zero. I'm also not clear on why your top bar disappears when it gets behind the window. You said you're using 3.0.4, and 3.0.4 enforces the draw order based on depth, not Z.

vexe

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 153
    • View Profile
Thanks for your reply. I didn't have to do anything with the code, I just selected the whole UI hierarchy (starting from "(Panel) - ItemBox") and set their Z position to 0, it appears to have worked. I don't know why that fixes it, but it seems it does. I was also surprised as much as you are by the fact that the bar disappears when it gets behind the window... I don't know.

I hope this gave you some bugs/ideas/things to consider in your next release.

I guess you could easily re-produce what I have, and see for yourself.

Thanks for your help.

vexe

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 153
    • View Profile
One more thing if you please, if you notice in my setup, I also have UIAnchor and UIStretch on my clipping panel, so whenever I reposition I want the clipping to resize correctly, but it's not working right. It's not resizing correctly.

Is this a proper way of doing it? or is there another way? or could this be yet another thing to consider in your next release?

vexe

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 153
    • View Profile
Since I thought this is a useful question for others, I asked in a separate thread.

Please take a look http://www.tasharen.com/forum/index.php?topic=6572.0