Author Topic: unity editor and ios device drawing order is not consistent.  (Read 4198 times)

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
unity editor and ios device drawing order is not consistent.
« on: April 27, 2012, 12:23:12 AM »
I am using NGUI 2.0.3e, Unity3d 3.5.1 and tested on iPhone 3GS, iPad1

UIPanel
--UISprite
--UILabel

the UISprite and UILabel with different Material and its Z order is 0.

In the Unity Editor, UISprite is on top of UILabel, while in iOS devices, UILabel is on top of UISprite.




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: unity editor and ios device drawing order is not consistent.
« Reply #1 on: April 27, 2012, 12:27:46 AM »
If they use different materials, you need to tell Unity which one is in front by adjusting the Z.

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: unity editor and ios device drawing order is not consistent.
« Reply #2 on: April 27, 2012, 12:29:31 AM »
Is it very hard to make the iOS device and Unity3d editor behave the same ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: unity editor and ios device drawing order is not consistent.
« Reply #3 on: April 27, 2012, 12:31:29 AM »
It's easy. As I said, adjust the Z. Bring one of them forward (the label) by adjusting the transform's Z (set it to -1).

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: unity editor and ios device drawing order is not consistent.
« Reply #4 on: April 27, 2012, 02:15:41 AM »
If they have the same Z and are in different atlases, it's a little bit random which gets drawn first - so don't do that. It's the same if things in the same atlas have the same depth. Having things in the same atlas and not setting depth to something different is bad, mkay?

Remember if you have two atlases, you need to bring forward everything from the one you want most forward, or split it up into different Panels, otherwise things will get weird if you for any reason disable the one thing brought forward on the z axis, like in a scroll view.

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: unity editor and ios device drawing order is not consistent.
« Reply #5 on: April 27, 2012, 02:49:16 AM »
but it is pretty trouble if there are so many UISprite and UILabel over the screen, as what i expected is what I see in editor should be the same as device.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: unity editor and ios device drawing order is not consistent.
« Reply #6 on: April 27, 2012, 04:12:02 AM »
Actually it's not guaranteed to stay the same in the editor. The results are undefined if you don't specify a different Z value. It's the same as specifying identical depth on widgets within the same atlas. Their order is undefined that way. One may be in front of the other in edit mode, then the opposite when you hit Play.