Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Graphics.DrawMeshInstancedIndirect and sprites draw order

Discussion in 'General Graphics' started by bitHussar, Dec 30, 2021.

  1. bitHussar


    Jan 9, 2016
    I'm working on a 2d side scroller game with large tile-based map. For the tile rendering I have made a custom script that renders the tiles using Graphics.DrawMeshInstancedIndirect and a custom shader. All other graphics for player, enemies, projectiles, etc... are rendered using simple SpriteRenderers.
    The map has 3 layers along the z axis: background (1), actual map (0), foreground (-1) and we use a perspective camera for the parallax effect.
    We would like the SpriteRenderers to be rendered between the actual map layer and the foreground, however I couldn't find a way to do it.
    Sorting layers for sprites is made for this very porpose but if I'm not mistaken they cannot be used with DrawMeshInstancedIndirect. Is there another way to do this or I'm going to have to replace all SpriteRenderers with custom rendering script and sort them manually?