logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class HudDragPlacement

    Turns a preview move gesture into a new authored HudOffset.

    Inheritance
    object
    HudDragPlacement
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameUi.Application.Placement
    Assembly: Serenity.GameUi.Application.dll
    Syntax
    public static class HudDragPlacement
    Remarks

    Pure and engine-free so the same maths runs in an EditMode test and in the preview window: given a gesture and the element it is dragging, the result never depends on anything the caller did not pass in.

    Methods

    Drag(IHudPlacedElement, HudDragGesture)

    Applies a move gesture to an element's offset.

    Declaration
    public static HudOffset Drag(IHudPlacedElement element, HudDragGesture gesture)
    Parameters
    Type Name Description
    IHudPlacedElement element

    The element being dragged.

    HudDragGesture gesture

    The gesture to apply.

    Returns
    Type Description
    HudOffset

    The new authored offset.

    ReferenceUnitsPerScreenPixel(float, float, float)

    How many reference-resolution units one screen pixel represents when a reference canvas of referenceWidth units is displayed inside a frame of frameWidth pixels at the given zoom.

    Declaration
    public static float ReferenceUnitsPerScreenPixel(float referenceWidth, float frameWidth, float contentScale)
    Parameters
    Type Name Description
    float referenceWidth

    The HUD's reference resolution width, in reference units.

    float frameWidth

    The preview frame's width, in screen pixels.

    float contentScale

    Zoom applied on top of the letterbox fit; higher means more zoomed in.

    Returns
    Type Description
    float

    Reference units per screen pixel.

    ScreenPixelsPerReferenceUnit(float, float, float)

    The exact inverse of ReferenceUnitsPerScreenPixel(float, float, float).

    Declaration
    public static float ScreenPixelsPerReferenceUnit(float referenceWidth, float frameWidth, float contentScale)
    Parameters
    Type Name Description
    float referenceWidth

    The HUD's reference resolution width, in reference units.

    float frameWidth

    The preview frame's width, in screen pixels.

    float contentScale

    Zoom applied on top of the letterbox fit; higher means more zoomed in.

    Returns
    Type Description
    float

    Screen pixels per reference unit.

    In this article
    © 2026 Serenity. All Rights Reserved