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

Avatar
  • 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


Thanks!

Reporting a bug? please specify Unity version:
2023.1.20f1
Reporting a bug? please specify Shapes version:
4.3.1
Reporting a bug? please specify Render Pipeline:
URP
Avatar
dawn

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

Avatar
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



Avatar
dawn

okay thank you !