# Canvas

> Element that can be used for screen rendering.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.UIModule
* **Inherits from:** [Behaviour](/engine/6000.0/script-reference/unityengine/behaviour.md)

```csharp
[RequireComponent(typeof(RectTransform))]
public sealed class Canvas : Behaviour
```

## Remarks

Elements on a canvas are rendered AFTER Scene rendering, either from an attached camera or using overlay mode.

## Examples

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;

// Create a Canvas that holds a Text GameObject.

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        GameObject myGO;
        GameObject myText;
        Canvas myCanvas;
        Text text;
        RectTransform rectTransform;

        // Canvas
        myGO = new GameObject();
        myGO.name = "TestCanvas";
        myGO.AddComponent<Canvas>();

        myCanvas = myGO.GetComponent<Canvas>();
        myCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
        myGO.AddComponent<CanvasScaler>();
        myGO.AddComponent<GraphicRaycaster>();

        // Text
        myText = new GameObject();
        myText.transform.parent = myGO.transform;
        myText.name = "wibble";

        text = myText.AddComponent<Text>();
        text.font = (Font)Resources.Load("MyFont");
        text.text = "wobble";
        text.fontSize = 100;

        // Text position
        rectTransform = text.GetComponent<RectTransform>();
        rectTransform.localPosition = new Vector3(0, 0, 0);
        rectTransform.sizeDelta = new Vector2(400, 200);
    }
}
```

## Properties

| Property                                                                                                                   | Description                                                                                                                                                                                                                                                                                                                                                                             |
| -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [additionalShaderChannels](/engine/6000.0/script-reference/unityengine/canvas/additionalshaderchannels.md)                 | Get or set the mask of additional shader channels to be used when creating the [Canvas](/engine/6000.0/script-reference/unityengine/canvas.md) mesh.                                                                                                                                                                                                                                    |
| [cachedSortingLayerValue](/engine/6000.0/script-reference/unityengine/canvas/cachedsortinglayervalue.md)                   | Cached calculated value based upon SortingLayerID.                                                                                                                                                                                                                                                                                                                                      |
| [isRootCanvas](/engine/6000.0/script-reference/unityengine/canvas/isrootcanvas.md)                                         | Is this the root [Canvas](/engine/6000.0/script-reference/unityengine/canvas.md)?                                                                                                                                                                                                                                                                                                       |
| [normalizedSortingGridSize](/engine/6000.0/script-reference/unityengine/canvas/normalizedsortinggridsize.md)               | The normalized grid size that the canvas will split the renderable area into.                                                                                                                                                                                                                                                                                                           |
| [overridePixelPerfect](/engine/6000.0/script-reference/unityengine/canvas/overridepixelperfect.md)                         | Allows for nested canvases to override pixelPerfect settings inherited from parent canvases.                                                                                                                                                                                                                                                                                            |
| [overrideSorting](/engine/6000.0/script-reference/unityengine/canvas/overridesorting.md)                                   | Allows for nested canvases to override the [Canvas.sortingOrder](/engine/6000.0/script-reference/unityengine/canvas/sortingorder.md) from parent canvases.                                                                                                                                                                                                                              |
| [pixelPerfect](/engine/6000.0/script-reference/unityengine/canvas/pixelperfect.md)                                         | Forces pixel alignment for elements in the canvas. It only applies when [Canvas.renderMode](/engine/6000.0/script-reference/unityengine/canvas/rendermode.md) is set to Screen Space.                                                                                                                                                                                                   |
| [pixelRect](/engine/6000.0/script-reference/unityengine/canvas/pixelrect.md)                                               | Get the render rect for the [Canvas](/engine/6000.0/script-reference/unityengine/canvas.md).                                                                                                                                                                                                                                                                                            |
| [planeDistance](/engine/6000.0/script-reference/unityengine/canvas/planedistance.md)                                       | How far away from the camera is the Canvas generated? It only applies when [Canvas.renderMode](/engine/6000.0/script-reference/unityengine/canvas/rendermode.md) is set to [RenderMode.ScreenSpaceCamera](/engine/6000.0/script-reference/unityengine/rendermode/screenspacecamera.md).                                                                                                 |
| [referencePixelsPerUnit](/engine/6000.0/script-reference/unityengine/canvas/referencepixelsperunit.md)                     | The number of pixels per unit that is considered the default.                                                                                                                                                                                                                                                                                                                           |
| [renderingDisplaySize](/engine/6000.0/script-reference/unityengine/canvas/renderingdisplaysize.md)                         | Returns the canvas display size based on the selected render mode and target display.                                                                                                                                                                                                                                                                                                   |
| [renderMode](/engine/6000.0/script-reference/unityengine/canvas/rendermode.md)                                             | Is the [Canvas](/engine/6000.0/script-reference/unityengine/canvas.md) in World or Overlay mode?                                                                                                                                                                                                                                                                                        |
| [renderOrder](/engine/6000.0/script-reference/unityengine/canvas/renderorder.md)                                           | The render order in which the canvas is being emitted to the Scene. (Read Only)                                                                                                                                                                                                                                                                                                         |
| [rootCanvas](/engine/6000.0/script-reference/unityengine/canvas/rootcanvas.md)                                             | Returns the [Canvas](/engine/6000.0/script-reference/unityengine/canvas.md) closest to root, by checking through each parent and returning the last canvas found. If no other canvas is found then the canvas will return itself.                                                                                                                                                       |
| [scaleFactor](/engine/6000.0/script-reference/unityengine/canvas/scalefactor.md)                                           | Scales the entire canvas, ensuring it fits the screen. It only applies when [Canvas.renderMode](/engine/6000.0/script-reference/unityengine/canvas/rendermode.md) is set to Screen Space.                                                                                                                                                                                               |
| [sortingLayerID](/engine/6000.0/script-reference/unityengine/canvas/sortinglayerid.md)                                     | Unique ID of the Canvas' sorting layer.                                                                                                                                                                                                                                                                                                                                                 |
| [sortingLayerName](/engine/6000.0/script-reference/unityengine/canvas/sortinglayername.md)                                 | Name of the Canvas' sorting layer.                                                                                                                                                                                                                                                                                                                                                      |
| [sortingOrder](/engine/6000.0/script-reference/unityengine/canvas/sortingorder.md)                                         | Canvas' order within a sorting layer.                                                                                                                                                                                                                                                                                                                                                   |
| [targetDisplay](/engine/6000.0/script-reference/unityengine/canvas/targetdisplay.md)                                       | For Overlay mode, display index on which the UI canvas will appear.                                                                                                                                                                                                                                                                                                                     |
| [updateRectTransformForStandalone](/engine/6000.0/script-reference/unityengine/canvas/updaterecttransformforstandalone.md) | Should the Canvas size be updated based on the render target when a manual Camera.Render call is performed.                                                                                                                                                                                                                                                                             |
| [vertexColorAlwaysGammaSpace](/engine/6000.0/script-reference/unityengine/canvas/vertexcoloralwaysgammaspace.md)           | Should the Canvas vertex color always be in gamma space before passing to the UI shaders in linear color space work flow.                                                                                                                                                                                                                                                               |
| [worldCamera](/engine/6000.0/script-reference/unityengine/canvas/worldcamera.md)                                           | [Camera](/engine/6000.0/script-reference/unityengine/camera.md) used for sizing the [Canvas](/engine/6000.0/script-reference/unityengine/canvas.md) when in Screen Space - Camera. Also used as the [Camera](/engine/6000.0/script-reference/unityengine/camera.md) that events will be sent through for a World Space [Canvas](/engine/6000.0/script-reference/unityengine/canvas.md). |

## Static Methods

| Method                                                                                                                 | Description                                                                                |
| ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| [ForceUpdateCanvases](/engine/6000.0/script-reference/unityengine/canvas/forceupdatecanvases.md)                       | Force all canvases to update their content.                                                |
| [GetDefaultCanvasMaterial](/engine/6000.0/script-reference/unityengine/canvas/getdefaultcanvasmaterial.md)             | Returns the default material that can be used for rendering normal elements on the Canvas. |
| [GetETC1SupportedCanvasMaterial](/engine/6000.0/script-reference/unityengine/canvas/getetc1supportedcanvasmaterial.md) | Gets or generates the ETC1 Material.                                                       |

## Static Events

| Member                                                                                               | Description                                                                                                         |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| [preWillRenderCanvases](/engine/6000.0/script-reference/unityengine/canvas/prewillrendercanvases.md) | Event that is called just before [Canvas](/engine/6000.0/script-reference/unityengine/canvas.md) rendering happens. |
| [willRenderCanvases](/engine/6000.0/script-reference/unityengine/canvas/willrendercanvases.md)       | Event that is called just before [Canvas](/engine/6000.0/script-reference/unityengine/canvas.md) rendering happens. |

## Inheritance

**Inherited Members:**

* [Behaviour.enabled](/engine/6000.0/script-reference/unityengine/behaviour/enabled.md)
* [Behaviour.isActiveAndEnabled](/engine/6000.0/script-reference/unityengine/behaviour/isactiveandenabled.md)
* [Component.GetComponent(Type)](/engine/6000.0/script-reference/unityengine/component/getcomponent.md#getcomponent\(type\))
* [Component.GetComponent\<T>()](/engine/6000.0/script-reference/unityengine/component/getcomponent.md)
* [Component.TryGetComponent(Type, Component)](/engine/6000.0/script-reference/unityengine/component/trygetcomponent.md)
* [Component.TryGetComponent\<T>(T)](/engine/6000.0/script-reference/unityengine/component/trygetcomponent.md)
* [Component.GetComponent(string)](/engine/6000.0/script-reference/unityengine/component/getcomponent.md#getcomponent\(string\))
* [Component.GetComponentInChildren(Type, bool)](/engine/6000.0/script-reference/unityengine/component/getcomponentinchildren.md#getcomponentinchildren\(type-bool\))
* [Component.GetComponentInChildren(Type)](/engine/6000.0/script-reference/unityengine/component/getcomponentinchildren.md#getcomponentinchildren\(type\))
* [Component.GetComponentInChildren\<T>(bool)](/engine/6000.0/script-reference/unityengine/component/getcomponentinchildren.md)
* [Component.GetComponentsInChildren(Type, bool)](/engine/6000.0/script-reference/unityengine/component/getcomponentsinchildren.md)
* [Component.GetComponentsInChildren\<T>(bool)](/engine/6000.0/script-reference/unityengine/component/getcomponentsinchildren.md#getcomponentsinchildrent\(bool\))
* [Component.GetComponentsInChildren\<T>(bool, List\<T>)](/engine/6000.0/script-reference/unityengine/component/getcomponentsinchildren.md)
* [Component.GetComponentsInChildren\<T>()](/engine/6000.0/script-reference/unityengine/component/getcomponentsinchildren.md#getcomponentsinchildrent\(\))
* [Component.GetComponentsInChildren\<T>(List\<T>)](/engine/6000.0/script-reference/unityengine/component/getcomponentsinchildren.md)
* [Component.GetComponentInParent(Type, bool)](/engine/6000.0/script-reference/unityengine/component/getcomponentinparent.md#getcomponentinparent\(type-bool\))
* [Component.GetComponentInParent(Type)](/engine/6000.0/script-reference/unityengine/component/getcomponentinparent.md#getcomponentinparent\(type\))
* [Component.GetComponentInParent\<T>(bool)](/engine/6000.0/script-reference/unityengine/component/getcomponentinparent.md#getcomponentinparentt\(bool\))
* [Component.GetComponentInParent\<T>()](/engine/6000.0/script-reference/unityengine/component/getcomponentinparent.md#getcomponentinparentt\(\))
* [Component.GetComponentsInParent(Type, bool)](/engine/6000.0/script-reference/unityengine/component/getcomponentsinparent.md)
* [Component.GetComponentsInParent\<T>(bool)](/engine/6000.0/script-reference/unityengine/component/getcomponentsinparent.md#getcomponentsinparentt\(bool\))
* [Component.GetComponentsInParent\<T>(bool, List\<T>)](/engine/6000.0/script-reference/unityengine/component/getcomponentsinparent.md)
* [Component.GetComponentsInParent\<T>()](/engine/6000.0/script-reference/unityengine/component/getcomponentsinparent.md#getcomponentsinparentt\(\))
* [Component.GetComponents(Type)](/engine/6000.0/script-reference/unityengine/component/getcomponents.md#getcomponents\(type\))
* [Component.GetComponents(Type, List\<Component>)](/engine/6000.0/script-reference/unityengine/component/getcomponents.md#getcomponents\(type-listcomponent\))
* [Component.GetComponents\<T>(List\<T>)](/engine/6000.0/script-reference/unityengine/component/getcomponents.md)
* [Component.GetComponents\<T>()](/engine/6000.0/script-reference/unityengine/component/getcomponents.md#getcomponentst\(\))
* [Component.GetComponentIndex()](/engine/6000.0/script-reference/unityengine/component/getcomponentindex.md)
* [Component.CompareTag(string)](/engine/6000.0/script-reference/unityengine/component/comparetag.md#comparetag\(string\))
* [Component.CompareTag(TagHandle)](/engine/6000.0/script-reference/unityengine/component/comparetag.md#comparetag\(taghandle\))
* [Component.SendMessageUpwards(string, Object, SendMessageOptions)](/engine/6000.0/script-reference/unityengine/component/sendmessageupwards.md#sendmessageupwards\(string-object-sendmessageoptions\))
* [Component.SendMessageUpwards(string, SendMessageOptions)](/engine/6000.0/script-reference/unityengine/component/sendmessageupwards.md#sendmessageupwards\(string-sendmessageoptions\))
* [Component.SendMessage(string, Object)](/engine/6000.0/script-reference/unityengine/component/sendmessage.md#sendmessage\(string-object\))
* [Component.SendMessage(string)](/engine/6000.0/script-reference/unityengine/component/sendmessage.md#sendmessage\(string\))
* [Component.SendMessage(string, Object, SendMessageOptions)](/engine/6000.0/script-reference/unityengine/component/sendmessage.md#sendmessage\(string-object-sendmessageoptions\))
* [Component.SendMessage(string, SendMessageOptions)](/engine/6000.0/script-reference/unityengine/component/sendmessage.md#sendmessage\(string-sendmessageoptions\))
* [Component.BroadcastMessage(string, Object, SendMessageOptions)](/engine/6000.0/script-reference/unityengine/component/broadcastmessage.md#broadcastmessage\(string-object-sendmessageoptions\))
* [Component.BroadcastMessage(string, SendMessageOptions)](/engine/6000.0/script-reference/unityengine/component/broadcastmessage.md#broadcastmessage\(string-sendmessageoptions\))
* [Component.transform](/engine/6000.0/script-reference/unityengine/component/transform.md)
* [Component.gameObject](/engine/6000.0/script-reference/unityengine/component/gameobject.md)
* [Component.tag](/engine/6000.0/script-reference/unityengine/component/tag.md)
* [Object.GetInstanceID()](/engine/6000.0/script-reference/unityengine/object/getinstanceid.md)
* [Object.GetHashCode()](/engine/6000.0/script-reference/unityengine/object/gethashcode.md)
* [Object.InstantiateAsync\<T>(T)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.Instantiate(Object, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion\))
* [Object.Instantiate(Object, Vector3, Quaternion, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion-transform\))
* [Object.Instantiate(Object)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object\))
* [Object.Instantiate(Object, Scene)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-scene\))
* [Object.Instantiate\<T>(T, InstantiateParameters)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, InstantiateParameters)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate(Object, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform\))
* [Object.Instantiate(Object, Transform, bool)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform-bool\))
* [Object.Instantiate\<T>(T)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform, bool)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Destroy(Object, float)](/engine/6000.0/script-reference/unityengine/object/destroy.md)
* [Object.DestroyImmediate(Object, bool)](/engine/6000.0/script-reference/unityengine/object/destroyimmediate.md)
* [Object.FindObjectsByType(Type, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectssortmode\))
* [Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectsinactive-findobjectssortmode\))
* [Object.DontDestroyOnLoad(Object)](/engine/6000.0/script-reference/unityengine/object/dontdestroyonload.md)
* [Object.FindObjectsByType\<T>(FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectssortmode\))
* [Object.FindObjectsByType\<T>(FindObjectsInactive, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectsinactive-findobjectssortmode\))
* [Object.FindFirstObjectByType\<T>()](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytypet\(\))
* [Object.FindAnyObjectByType\<T>()](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(\))
* [Object.FindFirstObjectByType\<T>(FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytypet\(findobjectsinactive\))
* [Object.FindAnyObjectByType\<T>(FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(findobjectsinactive\))
* [Object.FindFirstObjectByType(Type)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytype\(type\))
* [Object.FindAnyObjectByType(Type)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type\))
* [Object.FindFirstObjectByType(Type, FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytype\(type-findobjectsinactive\))
* [Object.FindAnyObjectByType(Type, FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type-findobjectsinactive\))
* [Object.ToString()](/engine/6000.0/script-reference/unityengine/object/tostring.md)
* [Object.name](/engine/6000.0/script-reference/unityengine/object/name.md)
* [Object.hideFlags](/engine/6000.0/script-reference/unityengine/object/hideflags.md)

### Operators

| Operator                                                                           | Description                                                             |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [operator ==](/engine/6000.0/script-reference/unityengine/object/op-equality.md)   | Compares two object references to see if they refer to the same object. |
| [bool](/engine/6000.0/script-reference/unityengine/object/op-implicit.md)          | Determines whether the object exists.                                   |
| [operator !=](/engine/6000.0/script-reference/unityengine/object/op-inequality.md) | Compares if two objects refer to a different object.                    |
