# What determines canvas render order?

**URL:** https://discussions.unity.com/t/what-determines-canvas-render-order/549537
**Category:** UGUI
**Tags:** UGUI
**Created:** [September 5, 2014, 5:45am UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537 "2014-09-05T05:45:11Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![User340](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@User340](https://discussions.unity.com/u/User340)
#### Post date: [September 5, 2014, 5:45am UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/1 "2014-09-05T05:45:11Z")

</div>

When you have more than one Canvas in the scene, what determines which ones get drawn first?

I am specifically referring to the Screen Space - Overlay mode, the other ones seem obvious.

---

<div class="post-metadata">

### Author: ![phil-Unity](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@phil-Unity](https://discussions.unity.com/u/phil-Unity)
#### Post date: [September 5, 2014, 12:53pm UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/2 "2014-09-05T12:53:24Z")

</div>

The draw order is determine by the z position for Screen Space - Overlay canvas’s. I might try and change this to be hierarchy as well, i’d just need to find reliable data to do so.

---

<div class="post-metadata">

### Author: ![StarManta](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/starmanta/32/280327_2.png) [@StarManta](https://discussions.unity.com/u/StarManta)
#### Post date: [September 5, 2014, 12:57pm UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/3 "2014-09-05T12:57:30Z")

</div>

> [@phil-Unity](#):
>
> The draw order is determine by the z position for Screen Space - Overlay canvas’s. I might try and change this to be hierarchy as well, i’d just need to find reliable data to do so.

If the Z positions are equal, then sorting by transform order is sensible, but if they aren’t please don’t. I can think of no scenario where I would want one UI element to be drawn behind another when its position is in front - it’ll only confuse newbies and irritate everyone else.

---

<div class="post-metadata">

### Author: ![User340](https://avatars.discourse-cdn.com/v4/letter/u/bbe5ce/32.png) [@User340](https://discussions.unity.com/u/User340)
#### Post date: [September 5, 2014, 6:11pm UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/4 "2014-09-05T18:11:50Z")

</div>

Hmm, I’m having trouble modifying the z position. For one, it’s grayed out in the inspector (driven by Canvas). When I move the z position in the Scene view it has no effect on the draw order. Am I missing something?

---

<div class="post-metadata">

### Author: ![phil-Unity](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@phil-Unity](https://discussions.unity.com/u/phil-Unity)
#### Post date: [September 8, 2014, 10:13am UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/5 "2014-09-08T10:13:29Z")

</div>

So that’d be a bug :(. Either way we are working on unifying the sorting methodology so we dont have multiple ways of changing the order. This will come in a later beta.

---

<div class="post-metadata">

### Author: ![alti](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@alti](https://discussions.unity.com/u/alti)
#### Post date: [October 25, 2015, 9:45pm UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/6 "2015-10-25T21:45:45Z")

</div>

You can create another camera in the scene and put its depth at an integer above the other camera.

> create a new Layer (inspector \> top right) \> name it “UI2”  
> create new cam \> name it CamUI2  
> set CamUI2’s depth great than the other Camera’s depth  
> Set CamUI2’s Culling mask: “UI2”  
> go to other camera \> Culling mask: everything but UI2  
> go to the canvas you wanna render on top \>  
> make sure the layer of that canvas (top right of inspector) of it and its children are set to “UI2”  
> drag the CamUI2 camera into the render camera parameter on the UI2 canvas.

---

<div class="post-metadata">

### Author: ![callen](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@callen](https://discussions.unity.com/u/callen)
#### Post date: [February 16, 2016, 8:36pm UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/7 "2016-02-16T20:36:08Z")

</div>

So is @alti the only solution, using 2 cameras? Seems like it should be easier than that…

---

<div class="post-metadata">

### Author: ![MikHaven](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@MikHaven](https://discussions.unity.com/u/MikHaven)
#### Post date: [May 5, 2016, 12:45pm UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/8 "2016-05-05T12:45:16Z")

</div>

@callen since I got roped into this too, let me explain how to fix the problem, as of the new Unity version.

Canvas 0 - Screen Space Overlay.  
Sorting Layer = 1  
Canvas 1 - Screen Space Overlay  
Sorting Layer = 0

Now your canvas will sort based on this, and your Menu (Canvas 0) since its sorting layer is higher, as above solution will render on top of the game (Canvas 1)

---

<div class="post-metadata">

### Author: ![keblight](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@keblight](https://discussions.unity.com/u/keblight)
#### Post date: [November 29, 2018, 4:38am UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/9 "2018-11-29T04:38:03Z")

</div>

Thanks for this

---

<div class="post-metadata">

### Author: ![usernameHed](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/usernamehed/32/520384_2.png) [@usernameHed](https://discussions.unity.com/u/usernameHed)
#### Post date: [October 19, 2020, 12:05am UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/10 "2020-10-19T00:05:47Z")

</div>

Hello, if the Sorting Layer is the same for 2 canvas, how do I know which one will be in front ?

---

<div class="post-metadata">

### Author: ![StarManta](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/starmanta/32/280327_2.png) [@StarManta](https://discussions.unity.com/u/StarManta)
#### Post date: [October 19, 2020, 12:23am UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/11 "2020-10-19T00:23:18Z")

</div>

> [@usernameHed](#):
>
> Hello, if the Sorting Layer is the same for 2 canvas, how do I know which one will be in front ?

You don’t. The order is undefined, so it won’t be predictable.  
More than likely it will be based on the order of the transforms in the hierarchy, but you should NOT rely on that if the layering of the canvases matters.

---

<div class="post-metadata">

### Author: ![phil-Unity](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@phil-Unity](https://discussions.unity.com/u/phil-Unity)
#### Post date: [October 19, 2020, 3:12pm UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/12 "2020-10-19T15:12:05Z")

</div>

If the Sorting Layer is the same And the sorting order is the same then its not defined its done by first instantiation which could change depending on how your scene is set up.

---

<div class="post-metadata">

### Author: ![KaLaniC](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@KaLaniC](https://discussions.unity.com/u/KaLaniC)
#### Post date: [May 9, 2022, 7:05am UTC](https://discussions.unity.com/t/what-determines-canvas-render-order/549537/13 "2022-05-09T07:05:42Z")

</div>

> [@MikHaven](#):
>
> @callen since I got roped into this too, let me explain how to fix the problem, as of the new Unity version.
> 
> Canvas 0 - Screen Space Overlay.  
> Sorting Layer = 1  
> Canvas 1 - Screen Space Overlay  
> Sorting Layer = 0
> 
> Now your canvas will sort based on this, and your Menu (Canvas 0) since its sorting layer is higher, as above solution will render on top of the game (Canvas 1)

I I’ve sent hours trying to solve my issue reading using two Canvas where one was the game screen and the other was a pause menu. It worked but in game mode it didn’t and only played the game screen buttons but the the pause menu. Thank you so much! I prayed and then I seen this ! lol. I’m currently doing a project that’s 50% of my grade.
