logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Struct PreviewElementPlacement

    One element's placement, as the manipulation stack sees it: everything IHudPlacedElement declares, plus scale, stretch and the parented flag a gesture also has to read.

    Implements
    IHudPlacedElement
    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    ValueType.ToString()
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetType()
    Namespace: Serenity.Ui.Infrastructure.Editor.Preview
    Assembly: Serenity.UnityUi.Infrastructure.Editor.dll
    Syntax
    public readonly struct PreviewElementPlacement : IHudPlacedElement
    Remarks

    Being an IHudPlacedElement is what lets an instance feed straight into HudDragPlacement.Drag and HudTransformPlacement.Resize/Rotate/Deform — the boxing that costs is one allocation per gesture frame, negligible next to the IMGUI pass around it.

    Immutable and read fresh every frame from TryReadPlacement(int, out PreviewElementPlacement) — there is no live reference to mutate, so WithGestureStart(HudOffset, float) is how a scale, deform or rotate gesture gets the frozen-at-gesture-start view HudTransformPlacement.Resize/Rotate/Deform need, without a separate wrapper type: it is the same data, just a copy with two fields overridden.

    Constructors

    PreviewElementPlacement(UiAnchorType, HudOffset, float, int, bool, float, float, float, bool)

    Creates a placement.

    Declaration
    public PreviewElementPlacement(UiAnchorType anchor, HudOffset offset, float rotationDegrees, int playerIndex, bool mirrorForPlayer, float scale, float stretchX, float stretchY, bool isPlacedByParent)
    Parameters
    Type Name Description
    UiAnchorType anchor

    Which screen corner or edge the element is anchored to.

    HudOffset offset

    The nudge from that anchor, in reference-resolution pixels.

    float rotationDegrees

    The turn applied to the whole element, in degrees.

    int playerIndex

    The player this element belongs to, or -1 when it is not player-scoped.

    bool mirrorForPlayer

    Whether a player-scoped element mirrors for odd player indices.

    float scale

    Uniform scale, applied around the element's anchor.

    float stretchX

    Stretch along the element's own local X axis.

    float stretchY

    Stretch along the element's own local Y axis.

    bool isPlacedByParent

    Whether a parent box places this element instead of its own anchor and offset.

    Properties

    Anchor

    Declaration
    public UiAnchorType Anchor { get; }
    Property Value
    Type Description
    UiAnchorType

    IsPlacedByParent

    Whether a parent box places this element instead of its own Anchor and Offset — a gesture has nothing to usefully write when this is set.

    Declaration
    public bool IsPlacedByParent { get; }
    Property Value
    Type Description
    bool

    MirrorForPlayer

    Declaration
    public bool MirrorForPlayer { get; }
    Property Value
    Type Description
    bool

    Offset

    Declaration
    public HudOffset Offset { get; }
    Property Value
    Type Description
    HudOffset

    PlayerIndex

    Declaration
    public int PlayerIndex { get; }
    Property Value
    Type Description
    int

    RotationDegrees

    Declaration
    public float RotationDegrees { get; }
    Property Value
    Type Description
    float

    Scale

    Uniform scale, applied around the element's anchor.

    Declaration
    public float Scale { get; }
    Property Value
    Type Description
    float

    StretchX

    Stretch along the element's own local X axis, before rotation.

    Declaration
    public float StretchX { get; }
    Property Value
    Type Description
    float

    StretchY

    Stretch along the element's own local Y axis, before rotation.

    Declaration
    public float StretchY { get; }
    Property Value
    Type Description
    float

    Methods

    WithGestureStart(HudOffset, float)

    A copy of this placement with its offset and rotation pinned to a gesture's starting values, everything else unchanged.

    Declaration
    public PreviewElementPlacement WithGestureStart(HudOffset offset, float rotationDegrees)
    Parameters
    Type Name Description
    HudOffset offset

    The element's authored offset when the gesture began.

    float rotationDegrees

    The element's authored rotation when the gesture began, in degrees.

    Returns
    Type Description
    PreviewElementPlacement

    The frozen placement.

    Remarks

    A scale, deform or rotate gesture is total-from-start: it re-solves from the same starting placement every frame rather than accumulating, which is what keeps a long drag from drifting off from float error. Passing the live placement straight in would feed the solver a placement that already carries the previous frame's write, compounding the compensation on every subsequent frame.

    Implements

    IHudPlacedElement
    In this article
    © 2026 Serenity. All Rights Reserved