Search Results for

    Show / Hide Table of Contents

    Class CanvasScaler

    UI canvas scaling component for user interface that targets multiple different game resolutions (eg. mobile screens).

    Inheritance
    System.Object
    Control
    ContainerControl
    CanvasScaler
    Implements
    System.IComparable
    IDrawable
    Inherited Members
    ContainerControl._children
    ContainerControl._containsFocus
    ContainerControl._isLayoutLocked
    ContainerControl.LockChildrenRecursive()
    ContainerControl.UnlockChildrenRecursive()
    ContainerControl.RemoveChildren()
    ContainerControl.DisposeChildren()
    ContainerControl.AddChild<T>()
    ContainerControl.AddChild<T>(T)
    ContainerControl.RemoveChild(Control)
    ContainerControl.GetChild(Int32)
    ContainerControl.GetChild<T>()
    ContainerControl.GetChildIndex(Control)
    ContainerControl.GetChildIndexAt(Float2)
    ContainerControl.GetChildAt(Float2)
    ContainerControl.GetChildAt(Float2, Func<Control, Boolean>)
    ContainerControl.GetChildAtRecursive(Float2)
    ContainerControl.GetClientArea()
    ContainerControl.SortChildren()
    ContainerControl.SortChildrenRecursive()
    ContainerControl.OnChildResized(Control)
    ContainerControl.OnChildrenChanged()
    ContainerControl.OnNavigate(NavDirection, Float2, Control, List<Control>)
    ContainerControl.CanNavigateChild(Control)
    ContainerControl.NavigationWrap(NavDirection, Float2, List<Control>, Float2)
    ContainerControl.UpdateContainsFocus()
    ContainerControl.UpdateChildrenBounds()
    ContainerControl.PerformLayoutAfterChildren()
    ContainerControl.OnDestroy()
    ContainerControl.Update(Single)
    ContainerControl.ClearState()
    ContainerControl.DrawSelf()
    ContainerControl.DrawChildren()
    ContainerControl.PerformLayout(Boolean)
    ContainerControl.OnMouseEnter(Float2)
    ContainerControl.OnMouseMove(Float2)
    ContainerControl.OnMouseLeave()
    ContainerControl.OnMouseWheel(Float2, Single)
    ContainerControl.OnMouseDown(Float2, MouseButton)
    ContainerControl.OnMouseUp(Float2, MouseButton)
    ContainerControl.OnMouseDoubleClick(Float2, MouseButton)
    ContainerControl.IsTouchPointerOver(Int32)
    ContainerControl.OnTouchEnter(Float2, Int32)
    ContainerControl.OnTouchDown(Float2, Int32)
    ContainerControl.OnTouchMove(Float2, Int32)
    ContainerControl.OnTouchUp(Float2, Int32)
    ContainerControl.OnTouchLeave(Int32)
    ContainerControl.OnCharInput(Char)
    ContainerControl.OnKeyDown(KeyboardKeys)
    ContainerControl.OnKeyUp(KeyboardKeys)
    ContainerControl.OnDragEnter(Float2, DragData)
    ContainerControl.OnDragMove(Float2, DragData)
    ContainerControl.OnDragLeave()
    ContainerControl.OnDragDrop(Float2, DragData)
    ContainerControl.OnSizeChanged()
    ContainerControl.Children
    ContainerControl.ChildrenCount
    ContainerControl.HasChildren
    ContainerControl.ContainsFocus
    ContainerControl.ClipChildren
    ContainerControl.CullChildren
    ContainerControl.IsTouchOver
    Control.Resize(Float2)
    Control.UpdateBounds()
    Control.UpdateTransform()
    Control.SetAnchorPreset(AnchorPresets, Boolean, Boolean)
    Control.Dispose()
    Control.Focus()
    Control.Defocus()
    Control.OnGotFocus()
    Control.OnLostFocus()
    Control.OnStartContainsFocus()
    Control.OnEndContainsFocus()
    Control.Focus(Control)
    Control.StartMouseCapture(Boolean)
    Control.EndMouseCapture()
    Control.OnEndMouseCapture()
    Control.GetNavTarget(NavDirection)
    Control.GetNavOrigin(NavDirection)
    Control.NavigationFocus()
    Control.OnSubmit()
    Control.OnTouchLeave()
    Control.DoDragDrop(DragData)
    Control.LinkTooltip(String, Tooltip)
    Control.UnlinkTooltip()
    Control.OnShowTooltip(String, Float2, Rectangle)
    Control.OnTooltipShown(Tooltip)
    Control.OnTestTooltipOverControl(Float2)
    Control.PointToParent(ContainerControl, Float2)
    Control.PointToParent(Float2)
    Control.PointFromParent(Float2)
    Control.PointFromParent(ContainerControl, Float2)
    Control.PointToWindow(Float2)
    Control.PointFromWindow(Float2)
    Control.PointToScreen(Float2)
    Control.PointFromScreen(Float2)
    Control.OnLocationChanged()
    Control.SetScaleInternal(Float2)
    Control.SetPivotInternal(Float2)
    Control.SetShearInternal(Float2)
    Control.SetRotationInternal(Single)
    Control.OnVisibleChanged()
    Control.OnParentChangedInternal()
    Control.AddUpdateCallbacks(RootControl)
    Control.RemoveUpdateCallbacks(RootControl)
    Control.SetUpdate(Control.UpdateDelegate, Control.UpdateDelegate)
    Control.OnParentResized()
    Control.CompareTo(Object)
    Control.Compare(Control)
    Control.Top
    Control.Bottom
    Control.Left
    Control.Right
    Control.UpperLeft
    Control.UpperRight
    Control.BottomRight
    Control.BottomLeft
    Control.Scale
    Control.Pivot
    Control.Shear
    Control.Rotation
    Control.HasParent
    Control.BackgroundColor
    Control.BackgroundBrush
    Control.Enabled
    Control.EnabledInHierarchy
    Control.Visible
    Control.VisibleInHierarchy
    Control.IsDisposing
    Control.Root
    Control.RootWindow
    Control.DpiScale
    Control.ScreenPos
    Control.AutoFocus
    Control.IsFocused
    Control.IsNavFocused
    Control.IsMouseOver
    Control.IsDragOver
    Control.Tooltip
    Control.ShowTooltip
    Control.LocationChanged
    Control.SizeChanged
    Control.ParentChanged
    Control.VisibleChanged
    Namespace: FlaxEngine.GUI
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [ActorToolbox("GUI")]
    public class CanvasScaler : ContainerControl, IComparable, IDrawable

    Constructors

    CanvasScaler()

    Initializes a new instance of the CanvasScaler class.

    Declaration
    public CanvasScaler()

    Fields

    DpiCurve

    The UI Canvas scaling curve based on screen DPI (key is DPI, value is scale factor). Used only in ScaleWithDpi mode.

    Declaration
    [EditorOrder(150)]
    [EditorDisplay("Canvas Scaler", null)]
    [VisibleIf("IsScaleWithDpi", false)]
    public LinearCurve<float> DpiCurve
    Field Value
    LinearCurve<System.Single>

    ResolutionCurve

    The UI Canvas scaling curve based on screen resolution - shortest/longest/vertical/horizontal (key is resolution, value is scale factor). Clear keyframes to skip using it and follow min/max rules only. Used only in ScaleWithResolution mode.

    Declaration
    [EditorOrder(140)]
    [EditorDisplay("Canvas Scaler", null)]
    [VisibleIf("IsScaleWithResolution", false)]
    public LinearCurve<float> ResolutionCurve
    Field Value
    LinearCurve<System.Single>

    Properties

    CurrentScale

    Gets the current UI scale. Computed based on the setup when performing layout.

    Declaration
    public float CurrentScale { get; }
    Property Value
    System.Single

    EditorBounds

    Bounds rectangle for editor UI.

    Declaration
    public override Rectangle EditorBounds { get; }
    Property Value
    Rectangle

    Overrides
    Control.EditorBounds

    PhysicalUnit

    The UI Canvas physical unit to use for scaling via PhysicalUnitSize. Used only in ConstantPhysicalSize mode.

    Declaration
    [EditorOrder(100)]
    [EditorDisplay("Canvas Scaler", null)]
    [VisibleIf("IsConstantPhysicalSize", false)]
    public CanvasScaler.PhysicalUnitMode PhysicalUnit { get; set; }
    Property Value
    CanvasScaler.PhysicalUnitMode

    PhysicalUnitSize

    The UI Canvas physical unit value. Used only in ConstantPhysicalSize mode.

    Declaration
    [EditorOrder(110)]
    [EditorDisplay("Canvas Scaler", null)]
    [Limit(1E-06F, 1000000F, 0F)]
    [VisibleIf("IsConstantPhysicalSize", false)]
    public float PhysicalUnitSize { get; set; }
    Property Value
    System.Single

    ResolutionMax

    The UI Canvas maximum resolution. If the screen has higher size, then the interface will be scaled accordingly. Used only in ScaleWithResolution mode.

    Declaration
    [EditorOrder(130)]
    [EditorDisplay("Canvas Scaler", null)]
    [VisibleIf("IsScaleWithResolution", false)]
    public Float2 ResolutionMax { get; set; }
    Property Value
    Float2

    ResolutionMin

    The UI Canvas minimum resolution. If the screen has lower size, then the interface will be scaled accordingly. Used only in ScaleWithResolution mode.

    Declaration
    [EditorOrder(120)]
    [EditorDisplay("Canvas Scaler", null)]
    [VisibleIf("IsScaleWithResolution", false)]
    public Float2 ResolutionMin { get; set; }
    Property Value
    Float2

    ResolutionMode

    The UI Canvas resolution scaling mode. Controls min/max resolutions usage in relation to the current screen resolution to compute the UI scale. Used only in ScaleWithResolution mode.

    Declaration
    [EditorOrder(120)]
    [EditorDisplay("Canvas Scaler", null)]
    [VisibleIf("IsScaleWithResolution", false)]
    public CanvasScaler.ResolutionScalingMode ResolutionMode { get; set; }
    Property Value
    CanvasScaler.ResolutionScalingMode

    ScaleFactor

    The UI Canvas scale. Applied in all scaling modes for custom UI sizing.

    Declaration
    [EditorOrder(10)]
    [EditorDisplay("Canvas Scaler", null)]
    [Limit(0.001F, 1000F, 0.01F)]
    public float ScaleFactor { get; set; }
    Property Value
    System.Single

    Scaling

    The UI Canvas scaling mode.

    Declaration
    [EditorOrder(0)]
    [EditorDisplay("Canvas Scaler", null)]
    [ExpandGroups]
    public CanvasScaler.ScalingMode Scaling { get; set; }
    Property Value
    CanvasScaler.ScalingMode

    Methods

    ContainsPoint(ref Float2, Boolean)

    Checks if this control contains given point in local Control Space.

    Declaration
    public override bool ContainsPoint(ref Float2 location, bool precise = false)
    Parameters
    Float2 location

    Point location in Control Space to check

    System.Boolean precise

    True if perform precise intersection test against the control content (eg. with hit mask or transparency threshold). Otherwise, only simple bounds-check will be performed.

    Returns
    System.Boolean

    True if point is inside control's area, otherwise false.

    Overrides
    ContainerControl.ContainsPoint(ref Float2, Boolean)

    Draw()

    Draw the control and the children.

    Declaration
    public override void Draw()
    Overrides
    ContainerControl.Draw()

    GetDesireClientArea(out Rectangle)

    Gets the desire client area rectangle for all the controls.

    Declaration
    public override void GetDesireClientArea(out Rectangle rect)
    Parameters
    Rectangle rect

    The client area rectangle for child controls.

    Overrides
    ContainerControl.GetDesireClientArea(out Rectangle)

    IntersectsChildContent(Control, Float2, out Float2)

    Checks if given point in this container control space intersects with the child control content. Also calculates result location in child control space which can be used to feed control with event at that point.

    Declaration
    public override bool IntersectsChildContent(Control child, Float2 location, out Float2 childSpaceLocation)
    Parameters
    Control child

    The child control to check.

    Float2 location

    The location in this container control space.

    Float2 childSpaceLocation

    The output location in child control space.

    Returns
    System.Boolean

    True if point is over the control content, otherwise false.

    Overrides
    ContainerControl.IntersectsChildContent(Control, Float2, out Float2)

    IntersectsContent(ref Float2, out Float2)

    Checks if given location point in Parent Space intersects with the control content and calculates local position.

    Declaration
    public override bool IntersectsContent(ref Float2 locationParent, out Float2 location)
    Parameters
    Float2 locationParent

    The location in Parent Space.

    Float2 location

    The location of intersection in Control Space.

    Returns
    System.Boolean

    True if given point in Parent Space intersects with this control content, otherwise false.

    Overrides
    Control.IntersectsContent(ref Float2, out Float2)

    PerformLayoutBeforeChildren()

    Perform layout for that container control before performing it for child controls.

    Declaration
    protected override void PerformLayoutBeforeChildren()
    Overrides
    ContainerControl.PerformLayoutBeforeChildren()

    PointFromParent(ref Float2)

    Converts point in parent control coordinates into local control's space.

    Declaration
    public override Float2 PointFromParent(ref Float2 location)
    Parameters
    Float2 location

    Returns
    Float2

    The converted point location in control's space.

    Overrides
    Control.PointFromParent(ref Float2)

    PointToParent(ref Float2)

    Converts point in local control's space into parent control coordinates.

    Declaration
    public override Float2 PointToParent(ref Float2 location)
    Parameters
    Float2 location

    The input location of the point to convert.

    Returns
    Float2

    The converted point location in parent control coordinates.

    Overrides
    Control.PointToParent(ref Float2)

    RayCast(ref Float2, out Control)

    Performs a raycast against UI controls hierarchy to find any intersecting control content. Uses ContainsPoint(ref Float2, Boolean) with precise check (skips transparent surfaces and empty panels).

    Declaration
    public override bool RayCast(ref Float2 location, out Control hit)
    Parameters
    Float2 location

    The position to intersect UI with.

    Control hit

    The result control that intersects with the raycast.

    Returns
    System.Boolean

    True if ray hits any matching control, otherwise false.

    Overrides
    ContainerControl.RayCast(ref Float2, out Control)

    UpdateScale()

    Updates the scaler for the current setup.

    Declaration
    public void UpdateScale()

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.DeepClone<T>(T)
    Extensions.RawClone<T>(T)
    In This Article
    • Constructors
      • CanvasScaler()
    • Fields
      • DpiCurve
      • ResolutionCurve
    • Properties
      • CurrentScale
      • EditorBounds
      • PhysicalUnit
      • PhysicalUnitSize
      • ResolutionMax
      • ResolutionMin
      • ResolutionMode
      • ScaleFactor
      • Scaling
    • Methods
      • ContainsPoint(ref Float2, Boolean)
      • Draw()
      • GetDesireClientArea(out Rectangle)
      • IntersectsChildContent(Control, Float2, out Float2)
      • IntersectsContent(ref Float2, out Float2)
      • PerformLayoutBeforeChildren()
      • PointFromParent(ref Float2)
      • PointToParent(ref Float2)
      • RayCast(ref Float2, out Control)
      • UpdateScale()
    • Extension Methods
    Back to top Copyright © 2012-2024 Wojciech Figat