Is is possible to render IM canvas overlay shapes *above* certain/all canvas overlay ui elements (UI.Image etc)?

  • updated

If I understand correctly, the IM samples for overlay are experimental

I've tinkered with them to make some basic shapes drawing in canvas, and it works very well.

I've altered my panels to have a custom draw order relative to each other, but this only affects the order of Draw.Ring(...) etc calls, which all follow a Draw.ZTest = CompareFunction.Always from your ImmediateModeCanvas.cs sample

As it stands now, built-in overlay elements (UI.Image etc) will _always_ render above my IM shapes. Is it possible to render any/all of my shapes *above* any/all built-in overlay elements? They are within the same canvas, if that matters.

And here's a snippet of the frame debugger:

Image 792


Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:

checking in about this or if there's a better place to ask

Freya Holmér creator

Immediate mode drawing is generally injected into a specific camera, and for Overlay canvas UI I don't think it's possible to do that, you get no control over injection timing as overlay UI is always drawn last into the framebuffer directly (as far as I know)

If you want more control over the draw order and you still really want to use Overlay canvas, you'll have to put the immediate mode shape drawers in a separate canvas that's drawn after the other UI

However, if you use camera-based canvas UI, then shapes will by default be drawn on top of all your UI.

If you want more control, you can also play with the second parameter of the Draw.Command inside ImmediateModeCanvas.cs, though this will be applied globally unless you add some more code to handle setting it per-IM canvas or per canvas shape

Image 795


okay thank you !