Link Search Menu Expand Document


Based on UIView


The canvas view is used to render UI components and controls things like draw sort order, scaling and render mode. Can also be used to reduce draw calls by sectioning off portion of the UI (i.e. that changes a lot) into a separate canvas.

Dependency Properties

Name Type Description
AdditionalShaderChannels AdditionalCanvasShaderChannels Enum mask of possible shader channel properties that can also be included when the Canvas mesh is created.
Alignment ElementAlignment Used to align the view relative to the layout parent region it resides in.
Alpha float Can be used to adjust the alpha color of this view and all its children. E.g. used for fade in/out animations. Is separate from and different from the background color of the view as it affects the children as well.
BlockingObjects BlockingObjects Type of objects that will block graphic raycasts.
BubbleNotifyChildLayoutChanged bool Boolean indicating if parent always should be notified when the child changes layout.
CanvasScalerReferencePixelsPerUnit float If a sprite has ‘Pixels Per Unit’ setting, one pixel in the sprite will cover one unit in the UI.
CanvasScalerScaleFactor float Scales all children within the canvas by this factor.
DefaultSpriteDPI float The pixels per inch to use for sprites that have a ‘Pixels Per Unit’ setting that matches the ‘Reference Pixels Per Unit’ setting.
DisableLayoutUpdate bool Boolean indicating if automatic layout updates for this view should be disabled. When disabled the view doesn’t call UpdateLayout() when properties such as Width, Height, etc. changes.
DynamicPixelsPerUnit float The amount of pixels per unit to use for dynamically created bitmaps in the UI, such as Text.
EnableScriptEvents bool Boolean indicating if unity script events (Update, LateUpdate, Awake, etc) should be relayed to the view code-behind through the corresponding methods that can be overriden.
FallbackScreenDPI float The DPI to assume if the screen DPI is not known.
GameObject GameObject GameObject in the hierarchy that corresponds to the view.
Height ElementSize The height of the view in pixels or percents.
IgnoreFlip bool Used when doing localization override default behavior of flipping the view Right to Left or Left to Rigth.
IgnoreObject bool Boolean indicating if the view should be ignored. Ignored objects don’t run any load logic and don’t respond to property changed events.
IgnoreReversedGraphics bool Boolean indicating if graphics facing away from the raycaster should be ignored.
IsActive bool Boolean indicating if the view is active. Deactivated views deactivates corresponding game object, components, renderers and scripts.
IsVisible bool Boolean indicating if view is visible or hidden. Invisible views still take up space but aren’t interactable and have their alpha set to 0.
LoadMode LoadMode Enum flags indicating when and how the view should be loaded by the framework. Can be changed when e.g. the view is to be loaded on-demand.
Margin ElementMargin Adding margins to a view changes the size of the area in which its content resides, but it does not change the width or height of the view.
MatchWidthOrHeight float Setting to scale the Canvas to match the width or height of the reference resolution, or a combination.
NormalizedSortingGridSize float The normalized grid size that the canvas will split the renderable area into.
Offset ElementMargin Determines the offset of the view.
OffsetFromParent ElementMargin Offset set by a parent view. Used by views like Group to arrange children without changing their own Offset values.
OverrideHeight ElementSize Overrides regular Height value. Used to e.g. automatically size items without changing the default Height value set.
OverridePixelPerfect bool Allows for nested canvases to override pixelPerfect settings inherited from parent canvases.
OverrideSorting bool Override the sorting of canvas.
OverrideWidth ElementSize Overrides regular Width value. Used to e.g. automatically size items without changing the default Width value set.
PhysicalUnit Unit The physical unit to specify positions and sizes in.
Pivot Vector2 The pivot point of the view.
PixelPerfect bool Force elements in the canvas to be aligned with pixels. Only applies with renderMode is Screen Space.
PlaneDistance float How far away from the camera is the Canvas generated.
Position Vector3 Directly sets the local position of the view relative to parent. Position otherwise set using the Alignment and Offset properties.
RaycastBlockMode RaycastBlockMode Enum indicating if raycasts should be blocked.
ReferencePixelsPerUnit float The number of pixels per unit that is considered the default.
ReferenceResolution Vector2 The resolution the UI layout is designed for.
RenderCamera string ID of the world camera camera used when rendering the canvas.
RenderMode RenderMode Enum indicating if the canvas is in world or overlay mode.
Rotation Quaternion Rotation of the view.
Scale Vector3 Scale of the view.
ScaleFactor float Used to scale the entire canvas, while still making it fit the screen. Only applies with renderMode is Screen Space.
ScreenMatchMode ScreenMatchMode A mode used to scale the canvas area if the aspect ratio of the current resolution doesn’t fit the reference resolution.
SortingLayerID int Unique ID of the Canvas sorting layer.
SortingLayerName string Name of the Canvas sorting layer.
SortingOrder int Canvas order within a sorting layer.
TargetDisplay int For Overlay mode, display index on which the UI canvas will appear.
UiScaleMode ScaleMode Determines how UI elements in the Canvas are scaled.
UseFastShader bool Boolean indicating if the default UI shader should be replaced by a simpler and faster one. The faster shader does not support masking and clipping.
Width ElementSize The width of the view in pixels or percents.
WorldCamera Camera Reference to the world camera, is automatically set if RenderCamera is set.