Author Topic: weird problem with UILabel text always appearing in front of everything  (Read 6311 times)

lbzzbl

  • Guest
have been using NGUI recently for a game that i'm developing.  still new at this.

background:
i'm using 1 atlas
i'm using just 1 big panel (like main screen UI) with lots of buttons here and there.
when i clicked on a button, a window (say window1) will appear in the middle of the screen (just using NGUITools.SetActive to activate the relevant gameObject).

but i found a very weird problem, which is that if i have a UILabel text on a button in the main screen UI, even when window1 appears, the text on the UILabel will appear infront of window1.  naturally, the idea is to have the window "overlap" on top of what's on the main screen UI. 

i had checked the depth layers, and all appears to be correct, with the window1 depth layers to be higher in number (technically, will appear in front).

i asked a fellow developer, and he suggested using the z coordinates, which seemed to work.  but is this the correct solution?  maybe i'm doing something wrong with NGUI?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Check the FAQ. Different atlases = different draw calls. Depth only works within the same panel, and assuming it uses the same atlas.

lbzzbl

  • Guest
hi,

i did check the faq.  in this case, i'm using the same atlas.  and also the same panel...

with those conditions assumed, i'm still facing the problem where the UILabel's text appears always appearing in front...?

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
When you say "use Z coordinates" what do you mean?  Can you give specifics of how you adjusted the Z of the label to compensate?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
There is no case why this would happen. If the label is in front it's because:

If it uses the same atlas and same panel, then it must have a higher depth.

If it uses a different atlas and/or panel, then it has a lower Z position.

Check the panel tool. Chances are you have more panels than you think.

lbzzbl

  • Guest
hi,

when i meant z coordinates, i meant that in 3d space, i'm moving the window such that it is infront of the label.  in this case, it seems to work fine.

i'm not too familiar with the panel tool, i clicked on it, and found that there is only 1 panel, with 2 draw calls. 
is this normal?

Xanatus

  • Guest
i'm not too familiar with the panel tool, i clicked on it, and found that there is only 1 panel, with 2 draw calls. 
is this normal?
How many atlas is it using? Maybe your font is in a different one. It hould be just one draw call to get the depth working.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
2 draw calls means you are using two different atlases, so my original "check the FAQ for an explanation" answer stands.

lbzzbl

  • Guest
doh...now i know why there is always 2 draw calls when it appears that i'm only using 1 atlas.  the 2nd atlas came from the fonts that i was using...dammit.

thanks a lot for the help.  let me look into putting the fonts into the same atlas...