Render Text Mesh Pro on top of Immediate Draw Mode shapes?
I have a grid of Lines drawing in Immediate Draw Mode. I want to place a text mesh pro object over them but the lines are always drawn on top of the text.
I have tried:
1. Changing the ZTest condition for my Lines
2. Settings the BlendMode to Opaque for my Lines
there are two things happening here!
1. Immediate mode drawing doesn't automatically sort, it will naively draw in the order you write the code, no matter what
2. Any renderers (such as TMP text) will render somewhere in the Unity render pipeline, usually along with transparent objects like any other objects in the world
so what can happen is that if #2 happens before #1, immediate mode can draw on top of things you don't want it to draw on top of
The easiest way to check what order things are happening in is to open the frame debugger in Unity, and step through to see how it all renders
That all being said, I think what you might want to do in this case is to either:
A: Draw the lines using components instead of immediate mode
B: Change the injection point of the Draw.Command (this is the second parameter of Draw.Command) to something earlier, such as CameraEvent.AfterForwardOpaque, if you're drawing opaque shapes. That way any transparent renderers will always be drawn after