Hello Guest

Author Topic: Specify sorting order for tilemap and tilemap layers?  (Read 5508 times)

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Specify sorting order for tilemap and tilemap layers?
« on: November 01, 2013, 08:23:04 pm »
This feature has come in very handy for regular sprites, I was wondering if there is any way to implement it into the tilemap layers.
For example my tilemap has two layers, and right now I have them set with a zOffset of 0 and .0001. This works for the most part, but I feel like I am still able to detect a small amount of flickering between the layers as they are not quite on the same z index. Is there a way for them to share the same Z with a different render order?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Specify sorting order for tilemap and tilemap layers?
« Reply #1 on: November 01, 2013, 11:39:38 pm »
I'll consider something like this after the next release, and Unity 4.3 is released.
If we did something for this, it'll likely be Unity 4.3 only.

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Re: Specify sorting order for tilemap and tilemap layers?
« Reply #2 on: November 02, 2013, 08:13:26 pm »
Is there anything I can hunt for in the source code that may let me accomplish this? Or is the code that handles the relevant functions too disparate?
I know Unity 4.3 is introducing new 2d tools, including render layers, are they also adding functionality for rendering on the same Z?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Specify sorting order for tilemap and tilemap layers?
« Reply #3 on: November 02, 2013, 10:07:13 pm »
Unity adds explicit layer controls in 4.3, pretty much like the layer setting in tk2d. In fact, the 4.3 compatible tk2d will simply use the unity parameter when running in 4.3

Right now, you'll need to modify the mesh bounds. You can hack this in tk2dTileMapMeshBuilder.cs, immediately after chunk.mesh.RecalculateBounds();

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Re: Specify sorting order for tilemap and tilemap layers?
« Reply #4 on: November 03, 2013, 07:41:57 pm »
thanks, I think I have a basic working version in, making use of the AdjustedMeshBounds function from tk2dbasesprite, and basically passing in the tilemap layer id in place of the render layer.

does the build function only get called once upon the creation of the tilemap itself? just want to know if I need to clean up the code a bit if it's something that gets called often.

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Re: Specify sorting order for tilemap and tilemap layers?
« Reply #5 on: November 03, 2013, 07:59:04 pm »
sorry dumb question, I can just use a print statement to see that it only runs once.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Specify sorting order for tilemap and tilemap layers?
« Reply #6 on: November 04, 2013, 12:59:04 pm »
It will run again if you modify tiles and call Build()...