Set object draw layer within Immediate Mode
I think it'd be super useful if we could set what layer an Immediate Mode Draw happens on with something like: `Draw.Layer = LayerMask.NameToLayer("UI");'
Or if it just draws to the layer of the object the script is attached to, like components already do:
Render layers are a camera property, and immediate mode isn't tied to cameras or even game objects, so layers don't always exist in these contexts. You can, for instance use immediate mode to draw to render textures, completely cameraless
so, in order for immediate mode to do this, it would have to:
A) know what layer to use for each draw call
B) know what layer mask the current camera is using
C) check layers in every draw call
A would be your proposed Draw.Layer
B is harder. It could be another property like Draw.LayerMaskContext, but it's a little esoteric and would have to be assigned manually
C means there will have to be a mask check in every Draw.X call. I don't think it would be expensive, but I feel like it goes against the idea of immediate mode always drawing when you tell it to draw. As in, it's not like they're TryDraw.X functions, they always draw, it's the, bottom line, final actual real drawing thingy!
Ideally it would auto-detect what context you're in, but, that's not really possible, given that you could be rendering into a render target while, say, Camera.current is also not null. Plus, nullchecking Camera.current would be a big overhead for something like immediate mode that should be as thin of a layer as possible
so uh, I think that's a way too long way of saying that I'm leaning towards no
you can, however, do this in your own code. If you're in, say, OnPostRender, you generally know what camera context it's currently rendering with