UI Render Order Question
Hello, I have some premade UI Elements that are drawn on the screen: These are drawn on a canvas.
The black lighting at the bottom of the screen is drawn using GUI.DrawTexture(), in the OnGUI() method:
And I am having an issue with render order. Other solutions suggest using GUI.depth however setting this in the script that has my OnGUI() method doesn't affect the draw order of the premade UI Elements and I am still left with the UI Elements being drawn before the texture.
I would like this to be the inverse where the windows are drawn on top of the texture, rather then behind it. Any Ideas?
Answer by Harinezumi · Feb 07, 2018 at 09:13 AM
Unfortunately, I don't think this is possible (see this forum thread), because (if I remember correctly) OnGUI() is drawing after "everything" has been rendered.
However, I think it is possible to set the source image of a Unity UI Image component to the output of a render texture. Maybe you could solve it this way?
BTW, cool visuals! :)
Great Idea for the Solution, I did the exact same thing I did in the images, just ins$$anonymous$$d, put a raw texture underneath all other UI elements and set the texture of the raw image to the one I was drawing before in the OnGUI() method.
Thanks so much for the help!
Your answer
Follow this Question
Related Questions
How do I render canvas to texture with proper transparency? 2 Answers
UI Image rendering artifacts when upgrading beyond Unity 5.5.5 0 Answers
2DToolkit Sprites on Native UI Canvas 0 Answers
A problem when we want to add a render texture to an image from another camera 0 Answers
How to change/fix Shader Graph node connection ports 3 Answers