logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityHudRepresentation

    How one HUD element turns its bound value into something on screen.

    Inheritance
    object
    UnityHudRepresentation
    UnityHudFlexboxRepresentation
    UnityHudGaugeRepresentation
    UnityHudIconSetRepresentation
    UnityHudLabelRepresentation
    UnityHudSegmentedRepresentation
    UnityHudSpriteRepresentation
    UnityHudStackRepresentation
    UnityHudTextualRepresentation
    Implements
    IHudRepresentation
    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.Representations
    Assembly: Serenity.UnityGameUi.Infrastructure.dll
    Syntax
    public abstract class UnityHudRepresentation : IHudRepresentation
    Remarks

    A polymorphic [SerializeReference] hierarchy, the shape the Feedback aggregate already uses for its effects: new representations are added by subclassing, and the builder tool discovers them.

    Constructors

    UnityHudRepresentation()

    Declaration
    protected UnityHudRepresentation()

    Properties

    FollowsTheme

    Whether this representation completes itself from the theme.

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

    A choice rather than a convention, because the two ways a project wants to work are both legitimate. A game whose HUD is drawn to match one visual identity wants the theme to supply what it can; a game with bespoke HUD art wants swapping the menu theme to leave the HUD exactly where it was. Neither can be inferred, so it is asked.

    It also makes "nothing here" expressible. While the theme is consulted for anything unset, an empty sprite can only ever mean "inherit" — there is no way to say "draw the plain rectangle, ignore the theme". Turning this off is that sentence.

    HasThemedChrome

    Whether this representation has chrome a theme could contribute to, so the builder only offers the choice where it changes anything.

    Declaration
    public virtual bool HasThemedChrome { get; }
    Property Value
    Type Description
    bool

    Kind

    Declaration
    public abstract HudRepresentationKind Kind { get; }
    Property Value
    Type Description
    HudRepresentationKind

    Methods

    CreateRenderer()

    Creates the object that builds and drives this representation's visuals.

    Declaration
    public abstract IHudRepresentationRenderer CreateRenderer()
    Returns
    Type Description
    IHudRepresentationRenderer

    A renderer bound to this configuration.

    OrTheme(Sprite, Sprite)

    Returns own unless it is unset and the theme is being followed.

    Declaration
    protected Sprite OrTheme(Sprite own, Sprite themeFallback)
    Parameters
    Type Name Description
    Sprite own

    The element's sprite.

    Sprite themeFallback

    The theme's fallback.

    Returns
    Type Description
    Sprite
    Remarks

    The element is the authority for a HUD's art; the theme only fills gaps, and only when asked to.

    OrTheme(Vector2, Vector2)

    Returns own unless it is zero on either axis and the theme is being followed. A zero-sized HUD element is never intended, so zero reads as "not authored".

    Declaration
    protected Vector2 OrTheme(Vector2 own, Vector2 themeFallback)
    Parameters
    Type Name Description
    Vector2 own

    The element's size.

    Vector2 themeFallback

    The theme's fallback.

    Returns
    Type Description
    Vector2

    Implements

    IHudRepresentation
    In this article
    © 2026 Serenity. All Rights Reserved