Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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?