Class Canvas
A Canvas is a VisualElement that can be used to group other VisualElements. You can use it to create a scrollable area inside a window.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public class Canvas : BaseVisualElement, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IContextOverrideElement, IAdditionalDataHolder
Constructors
Canvas()
Instantiates a Canvas element.
Declaration
public Canvas()
Fields
backgroundUssClassName
USS class name of the background element of this type.
Declaration
public const string backgroundUssClassName = "appui-canvas__background"
Field Value
Type | Description |
---|---|
string |
cursorUssClassName
USS class name prefix for the cursor.
Declaration
public const string cursorUssClassName = "cursor--"
Field Value
Type | Description |
---|---|
string |
horizontalScrollerUssClassName
USS class name of the horizontal scroller element of this type.
Declaration
public const string horizontalScrollerUssClassName = "appui-canvas__horizontal-scroller"
Field Value
Type | Description |
---|---|
string |
ussClassName
USS class name of elements of this type.
Declaration
public const string ussClassName = "appui-canvas"
Field Value
Type | Description |
---|---|
string |
verticalScrollerUssClassName
USS class name of the vertical scroller element of this type.
Declaration
public const string verticalScrollerUssClassName = "appui-canvas__vertical-scroller"
Field Value
Type | Description |
---|---|
string |
viewportContainerUssClassName
USS class name of the viewport container element of this type.
Declaration
public const string viewportContainerUssClassName = "appui-canvas__viewport-container"
Field Value
Type | Description |
---|---|
string |
viewportUssClassName
USS class name of the viewport element of this type.
Declaration
public const string viewportUssClassName = "appui-canvas__viewport"
Field Value
Type | Description |
---|---|
string |
Properties
contentContainer
The content container of the Canvas.
Declaration
public override VisualElement contentContainer { get; }
Property Value
Type | Description |
---|---|
VisualElement |
Overrides
controlScheme
The current control scheme of the canvas.
Declaration
public CanvasControlScheme controlScheme { get; set; }
Property Value
Type | Description |
---|---|
CanvasControlScheme |
dampingEffectDuration
The damping effect duration in milliseconds.
Declaration
public int dampingEffectDuration { get; set; }
Property Value
Type | Description |
---|---|
int |
frameContainer
The container used for framing the Canvas.
Declaration
public Optional<Rect> frameContainer { get; set; }
Property Value
Type | Description |
---|---|
Optional<Rect> |
Remarks
The container rect value must be defined in the Canvas' local coordinates.
frameMargin
The margin applied when framing the Canvas.
Declaration
public float frameMargin { get; set; }
Property Value
Type | Description |
---|---|
float |
grabMode
The current grab state of the canvas (to pan).
Declaration
public GrabMode grabMode { get; }
Property Value
Type | Description |
---|---|
GrabMode |
maxZoom
The maximum zoom factor of the Canvas.
Declaration
public float maxZoom { get; set; }
Property Value
Type | Description |
---|---|
float |
minZoom
The minimum zoom factor of the Canvas.
Declaration
public float minZoom { get; set; }
Property Value
Type | Description |
---|---|
float |
panMultiplier
The pan multiplier when Shift key is hold.
Declaration
public float panMultiplier { get; set; }
Property Value
Type | Description |
---|---|
float |
primaryManipulator
The current manipulator of the canvas for the primary pointer without modifier.
Declaration
public CanvasManipulator primaryManipulator { get; set; }
Property Value
Type | Description |
---|---|
CanvasManipulator |
scrollDirection
The scroll direction of the Canvas. See ScrollDirection for more information.
Declaration
public ScrollDirection scrollDirection { get; set; }
Property Value
Type | Description |
---|---|
ScrollDirection |
scrollOffset
The scroll coordinates of the Canvas.
Declaration
public Vector2 scrollOffset { get; set; }
Property Value
Type | Description |
---|---|
Vector2 |
scrollSpeed
The scroll speed of the Canvas.
Declaration
public float scrollSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
useSpaceBar
Whether the Canvas should use the Space bar to pan.
Declaration
public bool useSpaceBar { get; set; }
Property Value
Type | Description |
---|---|
bool |
zoom
The zoom factor of the Canvas.
Declaration
public float zoom { get; set; }
Property Value
Type | Description |
---|---|
float |
zoomMultiplier
The zoom speed multiplier when Shift key is hold.
Declaration
public float zoomMultiplier { get; set; }
Property Value
Type | Description |
---|---|
float |
zoomSpeed
The zoom speed of the Canvas.
Declaration
public float zoomSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
FrameAll()
Frame the Canvas to see all elements.
Declaration
public void FrameAll()
FrameArea(Rect)
Frame the Canvas to the given area. The area is in the Viewport's local coordinates.
Declaration
public void FrameArea(Rect viewportArea)
Parameters
Type | Name | Description |
---|---|---|
Rect | viewportArea | The area to frame. |
FrameElement(VisualElement)
Frame the Canvas to the given element. The element is in the Viewport's local coordinates.
Declaration
public void FrameElement(VisualElement element)
Parameters
Type | Name | Description |
---|---|---|
VisualElement | element | The element to frame. |
FrameWorldRect(Rect)
Frame the Canvas to the given world area. The area is in world coordinates.
Declaration
public void FrameWorldRect(Rect worldRect)
Parameters
Type | Name | Description |
---|---|---|
Rect | worldRect | The area to frame. |
GetGrabModeUssClassName(GrabMode)
Declaration
public static string GetGrabModeUssClassName(GrabMode enumValue)
Parameters
Type | Name | Description |
---|---|---|
GrabMode | enumValue |
Returns
Type | Description |
---|---|
string |
Events
scrollOffsetChanged
Event that is triggered when the scroll position of the Canvas has changed.
Declaration
public event Action scrollOffsetChanged
Event Type
Type | Description |
---|---|
Action |
zoomChanged
Event that is triggered when the zoom factor of the Canvas has changed.
Declaration
public event Action zoomChanged
Event Type
Type | Description |
---|---|
Action |