logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityHudElementDefinition

    Inspector-authored implementation of IHudElementDefinition.

    Inheritance
    object
    UnityHudElementDefinition
    Implements
    IHudElementDefinition
    IFoundationSettings
    IHudPlacedElement
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameUi.Infrastructure.Settings
    Assembly: Serenity.UnityGameUi.Infrastructure.dll
    Syntax
    public class UnityHudElementDefinition : IHudElementDefinition, IFoundationSettings, IHudPlacedElement

    Constructors

    UnityHudElementDefinition()

    Declaration
    public UnityHudElementDefinition()

    Properties

    Anchor

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

    AnimationSettings

    The configured animations, in their concrete form, for the view and the HUD host to read the authored ProceduralAnimator layer from — the interface's own Animations only exposes what the engine-agnostic scanner needs.

    Declaration
    public IReadOnlyList<UnityHudElementAnimation> AnimationSettings { get; }
    Property Value
    Type Description
    IReadOnlyList<UnityHudElementAnimation>

    Animations

    Declaration
    public IReadOnlyList<IHudElementAnimationDefinition> Animations { get; }
    Property Value
    Type Description
    IReadOnlyList<IHudElementAnimationDefinition>

    CapacityBinding

    Declaration
    public IHudBinding CapacityBinding { get; }
    Property Value
    Type Description
    IHudBinding

    CapacityBindingSettings

    The capacity binding in its concrete form, or null when none is authored.

    Declaration
    public UnityHudBinding CapacityBindingSettings { get; }
    Property Value
    Type Description
    UnityHudBinding

    ChangeFeedbackCooldownSeconds

    Minimum time between two change-feedback plays on this element, in seconds.

    Declaration
    public float ChangeFeedbackCooldownSeconds { get; }
    Property Value
    Type Description
    float
    Remarks

    A negative value (unreachable through the inspector's [Min(0f)], but not through a recipe import or another authoring path) normalizes to zero. Zero itself is never normalized away — it is the deliberate, expressible choice to play on every qualifying change.

    ChangeFeedbackDefinitionId

    Declaration
    public string ChangeFeedbackDefinitionId { get; }
    Property Value
    Type Description
    string

    ChangeFeedbackDirection

    Declaration
    public HudValueChangeDirection ChangeFeedbackDirection { get; }
    Property Value
    Type Description
    HudValueChangeDirection

    Color

    Colour applied to the element's text when the theme's is not used.

    Declaration
    public Color Color { get; }
    Property Value
    Type Description
    Color

    EvaluatesThresholdsAsCapacityRatio

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

    Font

    Typeface applied to the element's text when the theme's is not used; null keeps whatever the created text object already had.

    Declaration
    public TMP_FontAsset Font { get; }
    Property Value
    Type Description
    TMP_FontAsset

    FontSize

    Font size for the element's text; zero keeps the template's own.

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

    GrowDirection

    Declaration
    public HudGrowDirection GrowDirection { get; }
    Property Value
    Type Description
    HudGrowDirection

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    HasCapacityBinding

    Whether a capacity binding has actually been authored.

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

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    IsTranslatingLabel

    Whether the caption is translated.

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

    Label

    The optional caption drawn beside the value.

    Declaration
    public string Label { get; }
    Property Value
    Type Description
    string

    MainAxisSize

    How this element sizes itself along its parent box's main axis; AUTO outside a box, or when none is authored — an element saved before this field existed deserializes it as AUTO with no migration step required.

    Declaration
    public LayoutSize MainAxisSize { get; }
    Property Value
    Type Description
    LayoutSize

    MirrorForPlayer

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

    Offset

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

    ParentId

    Declaration
    public string ParentId { get; }
    Property Value
    Type Description
    string

    PartSpacing

    Gap between the element's parts, when it does not follow the theme's rhythm.

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

    PlayerIndex

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

    PreviewCapacity

    Declaration
    public string PreviewCapacity { get; }
    Property Value
    Type Description
    string

    PreviewValue

    Declaration
    public string PreviewValue { get; }
    Property Value
    Type Description
    string

    RefreshSignalTypeName

    Declaration
    public string RefreshSignalTypeName { get; }
    Property Value
    Type Description
    string

    Representation

    Declaration
    public HudRepresentationKind Representation { get; }
    Property Value
    Type Description
    HudRepresentationKind

    RepresentationSettings

    The configured representation object.

    Declaration
    public UnityHudRepresentation RepresentationSettings { get; }
    Property Value
    Type Description
    UnityHudRepresentation

    RotationDegrees

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

    Scale

    Uniform scale for the whole element.

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

    One knob rather than a size on every part: resizing a HUD element means resizing its text, its sprites and its bar together, and doing that by hand across three fields is how they drift out of proportion. Applied around the element's anchor, so a scaled element stays where it was placed.

    StartsHidden

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

    Stretch

    Per-axis stretch applied to the element's own local X and Y axes, before rotation.

    Declaration
    public Vector2 Stretch { get; }
    Property Value
    Type Description
    Vector2
    Remarks

    The getter fallback below is the migration: an asset serialized before this field existed deserializes it as (0, 0), and a zero-or-negative component is normalized to 1 rather than stored — so an existing HUD keeps its uniform proportions with no manual step and no version bump.

    TextAlignment

    How the element's text is horizontally aligned in its box.

    Declaration
    public UiComponentAlignmentType TextAlignment { get; }
    Property Value
    Type Description
    UiComponentAlignmentType
    Remarks

    Never governed by UsesThemeText: that toggle is about lettering — a theme's typeface and colour — while alignment is layout, the same family as Scale and the anchor. An author who turns theme text on still owns where their own text sits.

    ThresholdRamp

    The element's threshold ramp, for the view — it needs the authored colours, not only the bounds the engine-agnostic interface exposes.

    Declaration
    public UnityHudThresholdRamp ThresholdRamp { get; }
    Property Value
    Type Description
    UnityHudThresholdRamp
    Remarks

    Never null: an element saved before this field existed deserializes it as null, and this getter falls back to a shared, band-less ramp rather than handing the view something it would have to null-check on every read. The fallback is never mutated, so sharing one instance across every legacy element is safe.

    ThresholdUpperBounds

    Declaration
    public IReadOnlyList<double> ThresholdUpperBounds { get; }
    Property Value
    Type Description
    IReadOnlyList<double>

    UpdateIntervalSeconds

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

    UpdateTrigger

    Declaration
    public HudUpdateTrigger UpdateTrigger { get; }
    Property Value
    Type Description
    HudUpdateTrigger

    UsesThemeSpacing

    Whether the gap between the element's parts comes from the theme.

    Declaration
    public bool UsesThemeSpacing { get; }
    Property Value
    Type Description
    bool
    Remarks

    On by default, alongside UsesThemeText: spacing is rhythm, and a HUD out of step with the rest of the interface reads as broken. Turning it off is how an element says its own gap is deliberate — including a gap of zero, which the previous "zero means inherit" rule could not express.

    UsesThemeText

    Whether the element writes its text the way the theme does — typeface and colour together.

    Declaration
    public bool UsesThemeText { get; }
    Property Value
    Type Description
    bool
    Remarks

    On by default, and one of the few places the theme still leads: a HUD in a different typeface or palette from the rest of the interface reads as broken, which is precisely what a theme prevents.

    Typeface and colour are one choice rather than two because they are never usefully mixed. Taking the theme's font but not its colour produces text that belongs to neither, and a project that wants its own HUD lettering wants both.

    ValueBinding

    Declaration
    public IHudBinding ValueBinding { get; }
    Property Value
    Type Description
    IHudBinding

    ValueBindingSettings

    The value binding in its concrete form, for the object reference it may carry.

    Declaration
    public UnityHudBinding ValueBindingSettings { get; }
    Property Value
    Type Description
    UnityHudBinding

    Methods

    SetLabel(string, bool)

    Sets the caption. Used by the builder tool.

    Declaration
    public void SetLabel(string caption, bool translated)
    Parameters
    Type Name Description
    string caption

    The caption text, or empty for none.

    bool translated

    Whether it is translated.

    SetPlacement(UiAnchorType, Vector2, HudGrowDirection)

    Sets the placement. Used by the builder tool.

    Declaration
    public void SetPlacement(UiAnchorType screenAnchor, Vector2 anchorOffset, HudGrowDirection direction)
    Parameters
    Type Name Description
    UiAnchorType screenAnchor

    The corner or edge to anchor to.

    Vector2 anchorOffset

    The nudge from that anchor.

    HudGrowDirection direction

    Which way repeating content extends.

    SetPreviewData(string, string)

    Sets the preview stand-ins. Used by the builder tool.

    Declaration
    public void SetPreviewData(string value, string capacity)
    Parameters
    Type Name Description
    string value

    Value to preview with.

    string capacity

    Maximum to preview with.

    SetRepresentation(UnityHudRepresentation)

    Sets the representation. Used by the builder tool.

    Declaration
    public void SetRepresentation(UnityHudRepresentation value)
    Parameters
    Type Name Description
    UnityHudRepresentation value

    The representation to apply.

    SetScale(float)

    Sets the uniform scale. Used by the builder tool.

    Declaration
    public void SetScale(float value)
    Parameters
    Type Name Description
    float value

    The scale factor.

    SetUpdatePolicy(HudUpdateTrigger, float, string)

    Sets the update policy. Used by the builder tool.

    Declaration
    public void SetUpdatePolicy(HudUpdateTrigger trigger, float intervalSeconds, string signalTypeName)
    Parameters
    Type Name Description
    HudUpdateTrigger trigger

    What makes the element re-read.

    float intervalSeconds

    Seconds between reads, for the interval trigger.

    string signalTypeName

    Signal type, for the on-signal trigger.

    Implements

    IHudElementDefinition
    IFoundationSettings
    IHudPlacedElement
    In this article
    © 2026 Serenity. All Rights Reserved