Search Unity

Tile Map Change "Order in Layer" of individual Tiles by Script

Discussion in '2D Experimental Preview' started by Dejan90, Feb 22, 2017.

  1. Dejan90

    Dejan90

    Joined:
    Jul 20, 2015
    Posts:
    2
    Hello,
    I'm currently using a script which is sorting certain gameobjects, within a sorting layer, by their y position. Now I want to do the same with all tiles, within a layer, of my tilemap. But I'm kind off lost by figuring out, how to get acess to the sorting order, of each tile. Can somebody help me, by telling me how to change the sorting order of tiles by scripts?
     
  2. snarlynarwhal

    snarlynarwhal

    Joined:
    Jan 16, 2014
    Posts:
    23
    This would be useful to me as well.
     
  3. kurasu1415

    kurasu1415

    Joined:
    Jan 27, 2015
    Posts:
    5
    Has anyone found a solution to this? I know how to write custom tiles but you don't seem to have access to a spriterenderer, only a sprite. I desperately need a solution here.
     
  4. snarlynarwhal

    snarlynarwhal

    Joined:
    Jan 16, 2014
    Posts:
    23
    I think that the tiles all render as a single mesh making it not possible at the moment.
     
  5. furroy

    furroy

    Joined:
    Feb 24, 2017
    Posts:
    93
    I worked around this by making multiple tilemaps with different sorting layers and put/move the tiles onto the appropriate tilemaps.
     
    tiskolin likes this.
  6. tiskolin

    tiskolin

    Joined:
    Sep 24, 2017
    Posts:
    249
    Incredibly simple, incredibly genius. Thank you.