logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Struct HudOffset

    A pixel offset from a HUD element's anchor, expressed in the project's reference resolution. Positive X is right, positive Y is up, regardless of which corner the element is anchored to — the anchor decides the origin, this decides the nudge.

    Implements
    IEquatable<HudOffset>
    Inherited Members
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetType()
    Namespace: Serenity.GameUi.Domain.ValueObjects
    Assembly: Serenity.GameUi.Domain.dll
    Syntax
    public readonly struct HudOffset : IEquatable<HudOffset>
    Remarks

    Deliberately not a Unity Vector2: the GameUi domain is engine-free, so the Unity layer converts.

    Constructors

    HudOffset(float, float)

    Creates an offset.

    Declaration
    public HudOffset(float x, float y)
    Parameters
    Type Name Description
    float x

    Horizontal offset in reference pixels.

    float y

    Vertical offset in reference pixels.

    Fields

    X

    Horizontal offset in reference pixels; positive is right.

    Declaration
    public readonly float X
    Field Value
    Type Description
    float

    Y

    Vertical offset in reference pixels; positive is up.

    Declaration
    public readonly float Y
    Field Value
    Type Description
    float

    Properties

    Zero

    No offset; the element sits exactly on its anchor.

    Declaration
    public static HudOffset Zero { get; }
    Property Value
    Type Description
    HudOffset

    Methods

    Equals(HudOffset)

    Declaration
    public bool Equals(HudOffset other)
    Parameters
    Type Name Description
    HudOffset other
    Returns
    Type Description
    bool

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    ValueType.Equals(object)

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()

    MirroredHorizontally()

    Returns this offset with its horizontal component negated.

    Declaration
    public HudOffset MirroredHorizontally()
    Returns
    Type Description
    HudOffset
    Remarks

    Used when an element is mirrored to the opposite side of the screen for another player.

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()

    Operators

    operator ==(HudOffset, HudOffset)

    Declaration
    public static bool operator ==(HudOffset left, HudOffset right)
    Parameters
    Type Name Description
    HudOffset left
    HudOffset right
    Returns
    Type Description
    bool

    operator !=(HudOffset, HudOffset)

    Declaration
    public static bool operator !=(HudOffset left, HudOffset right)
    Parameters
    Type Name Description
    HudOffset left
    HudOffset right
    Returns
    Type Description
    bool

    Implements

    IEquatable<T>
    In this article
    © 2026 Serenity. All Rights Reserved