Author Topic: Sprite sorting question  (Read 4192 times)

Donkey111

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 16
    • View Profile
Sprite sorting question
« on: September 22, 2013, 12:08:52 PM »
Sprite A and Sprite B both use the same atlas and are int the same anchor. Sprite A has a depth of -8. Sprite B has a depth of 2. Yet Sprite A sorts in front of Sprite B!

Sprite B is a dynamically created pre-fab. Could that be a reason it is not sorting in front of the background sprite? Any suggestions?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sprite sorting question
« Reply #1 on: September 23, 2013, 08:09:23 AM »
Upgrade to 3.0. 2.7 and earlier still have panels split draw calls and batch everything together. 3.0 is more careful in the matter and creates extra draw calls as needed.

Donkey111

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Sprite sorting question
« Reply #2 on: September 23, 2013, 01:57:01 PM »
My game is pretty far along. I'm concerned upgrading will require a lot of re-work.

But if that is the only solution, I will upgrade.

anord

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Sprite sorting question
« Reply #3 on: September 23, 2013, 10:41:23 PM »
NGUI 3.0 sorting question

prefab A - depth 100
Instantiate prefab A

ex) layer

A - depth 100
<--- how can i put some object between A?
A - depth 100
« Last Edit: September 23, 2013, 11:00:06 PM by anord »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Sprite sorting question
« Reply #4 on: September 24, 2013, 04:50:01 AM »
Donkey: You might have a Panel on the generated prefab - people tend to accidentally add it by editing the prefabs in the root of the hierarchy. Kill that off and it should sort properly.
Otherwise, make a backup and try to upgrade to 3.0 - if it fails, roll back and check the prefab properly.

anord: You should change the depth values run time so it's sorted the way you want.