Version: 2022.3
  • C#



Suggest a change


Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.


Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.




RenderMode for the Canvas.

//Attach this script to your Canvas GameObject

using UnityEngine;

public class Example : MonoBehaviour { enum RenderModeStates { camera, overlay, world }; RenderModeStates m_RenderModeStates;

Canvas m_Canvas;

// Use this for initialization void Start() { m_Canvas = GetComponent<Canvas>(); }

// Update is called once per frame void Update() { //Press the space key to switch between render mode states if (Input.GetKeyDown(KeyCode.Space)) { ChangeState(); } }

void ChangeState() { switch (m_RenderModeStates) { case m_Canvas.renderMode = RenderMode.ScreenSpaceCamera; m_RenderModeStates = RenderModeStates.overlay; break;

case RenderModeStates.overlay: m_Canvas.renderMode = RenderMode.ScreenSpaceOverlay; m_RenderModeStates =; break; case m_Canvas.renderMode = RenderMode.WorldSpace; m_RenderModeStates =;

break; } } }


ScreenSpaceOverlayRender at the end of the Scene using a 2D Canvas.
ScreenSpaceCameraRender using the Camera configured on the Canvas.
WorldSpaceRender using any Camera in the Scene that can render the layer.