Hello Guest

Author Topic: Unity 4.3 + tk2d Sprite depth  (Read 8890 times)

Absurditure

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Unity 4.3 + tk2d Sprite depth
« on: November 20, 2013, 09:08:41 pm »
I'm in the process of converting my project to the 2d physics system in 4.3.

Because the colliders all need to be at the same Z depth,  I can't use that as an easy way to control which objects are drawn in front of each other.  Is there a way to control the drawing depth, while still using 2D toolkit sprite collections?

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Re: Unity 4.3 + tk2d Sprite depth
« Reply #1 on: November 20, 2013, 09:17:42 pm »
on your tk2d sprite component there is a field called 'order in layer'
you can use that to determine what gets drawn on top. this works in conjunction with the unity 4.3 'sorting layers'

Absurditure

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Unity 4.3 + tk2d Sprite depth
« Reply #2 on: November 20, 2013, 10:31:49 pm »
Oh... Didn't see that there.  Thank you.

Absurditure

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Unity 4.3 + tk2d Sprite depth
« Reply #3 on: November 20, 2013, 10:48:12 pm »
Is there also a way to sort Tile Maps with the Unity sorting layers?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Unity 4.3 + tk2d Sprite depth
« Reply #4 on: November 21, 2013, 10:07:17 am »
Not yet there isn't. You could write something that assigns it at the end of tile map.Build() though, that should be easy enough and work pretty much straight away.

dustinbahr

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Unity 4.3 + tk2d Sprite depth
« Reply #5 on: November 22, 2013, 04:06:49 pm »
As a quick addition to this, when I upgraded to Unity 4.3 and 2dtoolkit 2.3.0, my sorting order got all messed up. It doesn't seem to be changing the sorting order as intended anymore.

Is this a bug, or did Unity 4.3 change the functionality of this? (I just want to keep the default layer and order some things on the same Z)

EDIT: It seems almost like sorting order is totally independent of z-layering now. Is this intended?
« Last Edit: November 22, 2013, 04:22:28 pm by dustinbahr »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Unity 4.3 + tk2d Sprite depth
« Reply #6 on: November 22, 2013, 04:26:08 pm »
Yes it is. Under Unity 4.3 it behaves exactly like that to work correctly with Unity sprites. Its easy to switch behaviours if you want to, but if you intend on using unity sprits in the future, its probably worth migrating over to this new behaviour.

dustinbahr

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Unity 4.3 + tk2d Sprite depth
« Reply #7 on: November 22, 2013, 04:28:15 pm »
How would you switch the behavior of it back? Pretty far along on this project and don't have use for Unity sprites just yet. :)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Unity 4.3 + tk2d Sprite depth
« Reply #8 on: November 22, 2013, 05:42:01 pm »
tk2dBaseSprite.SortingOrder, get rid of the Unity 4_3 path
tk2dBaseSprite.Awake, remove these lines:
Code: [Select]
#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
CachedRenderer.sortingOrder = renderLayer;
#endif
That should do it, I think.