Author Topic: UIInput and order of elements  (Read 5982 times)

sstublic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 15
    • View Profile
UIInput and order of elements
« on: February 20, 2013, 06:59:00 AM »
Hi!

We're building our entire UI with NGUI and I like most of it. Over the time I figured how to work with NGUI concepts, but there's one thing I can't figure out: order of elements.

My latest isssue is with UIInput. I created a simple input and my background sprite is hiding the text. Whatever I do except disabling background it doesn't work. However, if at runtime I change Z value of label it works.
If I set it at design time, it gets reset at runtime. Workaround is to set background Z value to positive (more distance from camera) and then it works. BUT, I never have a clue what value to set it to, because it might then go behind my other background on the same scene. I understand this is issue with different atlases in which NGUI's depth property is not working (is that correct?)

I've run into similar issues with other widgets and hierchies and mostly been solving it with trial and error by trying out different Z values, which is terrible.
Also I've been trying to set some Z positions from my code, but then I run into a problem which I guess is caused by the fact that NGUI uses 0.00025 multiplier for all positions?

I know this is not a clear question, but can you maybe shed some light or give some guidelines on how to handle order of UI elements when they're not in the same atlas?

I would very much like to do this in a proper and consistent manner instead of this blind trial and error.

Any help, guidelines or direction would be welcome.

Thanks!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput and order of elements
« Reply #1 on: February 20, 2013, 07:02:05 AM »
There are two sticky posts explaining this in this forum, and yet I still get this question... *sigh*

http://www.tasharen.com/forum/index.php?topic=6.msg238#msg238

http://www.tasharen.com/forum/index.php?topic=1858.0

sstublic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 15
    • View Profile
Re: UIInput and order of elements
« Reply #2 on: February 20, 2013, 07:06:01 AM »
Thanks, I'll read those...I hope they'll help

Such is the nature of users... :)

sstublic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 15
    • View Profile
Re: UIInput and order of elements
« Reply #3 on: February 20, 2013, 07:19:09 AM »
Sorry, but those still don't address my issues.

As I wrote I already know about different atlases and depth.

I'll try to be more clear

1. If UIInput is using different atlas for font and background, is changing the Z value of background my only option to make text visible? (changing it on label doesn't work)

2. If I have 2 sprites (A and B) at design time set to Z values -2 and -4 respectively; to what value do I set Z of sprite C so that is drawn between them? Do I use transforms position or localPosition? All sprites are from different atlases. (I was having issues with Z = -3, if this is the way it *should* work, I'll look for clearer example of what was the issue)

Thanks


Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIInput and order of elements
« Reply #4 on: February 20, 2013, 10:20:05 AM »
Remember that all sprites from a given atlas within the same panel are collapsed into a single draw call.

The order of the draw calls is where the final order is made.

If you have three sprites (A,B,C) from three different Atlases in the same panel and you want to order them ACB, then having it
A.z = 0
C.z = -1
B.z = -2

will be enough, ASSUMING that those are the only widgets from those three atlases. ALL widgets from the atlases should be in the same Z, otherwise it's undefined which gets drawn first. If you have a third sprite "D", which is from the same atlas as "A" and D.z = -3 then D and A will likely both be drawn on top of the other ones.



sstublic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 15
    • View Profile
Re: UIInput and order of elements
« Reply #5 on: February 20, 2013, 01:37:01 PM »
Thanks

I do use more widgets from those atlases and mostly this is where complications strike.

I should obviously, among other things, simplify my scene a bit...