Ordering under Canvas Decides Sorting Order on GUI in Unity
As we known, unity tutorial is too limited to reference on for most work. So it truly takes us a tons of time to debug the desired effects at some times, which happens to me. After a loop of online searches or trails, in the end, the solutions are not targeting my problems. At that disappointed moment, I realized that I should share solutions in public, since there must have people from unity community are looking for solutions to solve their problems. So I will share the problems that I encountered along with their solutions, in straight and simple way.
Example Problem:
In the above game view screenshot, you can see two Toggle Buttons floating over graph panel (only one main camera in the scene, and both are under it; Canvas render mode is Screen Space — Overlay). But it is expected to be shown in opposite sorting order — graph panel is in front of toggle buttons. So what solution do you first come up in your mind? Edit Pos Z values? That happened to me.
However, I suggest you go check their orders under Canvas.
You can see, under Canvas, Panel (graph panel) is staying before VArrowTog and AArrowTog (Toggle Buttons). Let us put Panel after two ArrowTogs as below:
Then this GUI sorting view problem solved.
So, be careful for ordering of gameobjects under Canvas, which decides their visual sorting order on GUI.
Welcome any comments.
Did you enjoy this post? Recommend it, by give it some claps. Thanks!