I'm using unity 5.3 and I'm trying to change the Rendering Order of two overlayed cross platform controls which each reside in their own canvas.
In previous versions you could bring the window into focus using
GUI.FocusWindow(0);
However this does not work with the new system. I've also tried modifying the order in the editor window which has done nothing.
Does anyone know how I can move a control to be on top of the other?
In the Built-in Render Pipeline, the order in which Unity renders objects is based on two things: which render queue the object is in, and how Unity sorts objects within that render queue. Unity sorts objects into groups called render queues.
Conventionally renderers in Unity will be sorted by several criteria such as Order in Layer or distance from camera. However, it was not possible to ensure that a group of renderers that share a common root be sorted together. Well, until now…
By default, Unity places objects in the render queue specified in their Unity shader. You define this value using the [Queue] SubShader tag. You can override this value on a per-material basis. In the Unity Editor, you can do this in the material Inspector by setting the Render Queue property.
You can set Sorting Layer and Order on a Canvas, so juggling multiple canvases is an awkward, but possible solution. I found this script on Unity Answers (can't find the original link) and there are similar scripts elsewhere. It exposes sorting layer/order for ALL mesh renderers!
After doing some research I found the proper way to change the Canvas Rendering Order. There is a property in the Canvas for the Sort Order, which is really the render order.
.
Just as a note remember the controls you want to be on top should have a larger order than the control on bottom.
Order in the editor window should work here. Are you sure you're changing the order of elements inside one canvas element?
Note that the order of elements in the Canvas game object is the order everything is rendered in - so the last thing you have in canvas will be the last thing drawn, so it will be on top of everything.
Here's how it works:
This is demonstrated with Unity 5.3.4, with much older Unity it can be different (there was a change of the way how children were enumerated somewhere in 5.0 or 5.1 AFAIK).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With