R. Jin
2 min readDec 19, 2018

--

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:

GUI Sorting 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.

This is the order from above problem.

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:

Panel after two ArrowTogs

Then this GUI sorting view problem solved.

Toggle Buttons are in back of graph panel in game view

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!

--

--

R. Jin

世界が终わるまでは… #watchman@CSUF#R&D #VR/AR #ML #randomblogging #solutionsharing #opinionsonmyown