logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class HudRenderResources

    The theme-derived building blocks a representation renders with, resolved once by the host and handed to every element so each one does not re-resolve the theme.

    Inheritance
    object
    HudRenderResources
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.GameUi.Infrastructure.Representations
    Assembly: Serenity.UnityGameUi.Infrastructure.dll
    Syntax
    public sealed class HudRenderResources

    Constructors

    HudRenderResources(IUiThemeDefinition)

    Creates a resource bundle from a theme alone, with no widget context.

    Declaration
    public HudRenderResources(IUiThemeDefinition theme)
    Parameters
    Type Name Description
    IUiThemeDefinition theme

    The theme to draw from.

    Remarks

    For the editor preview: there is no service locator at edit time, so the theme has to come straight from its asset. Without this the preview would fall through to bare text and would not show the look the theme actually gives the HUD.

    HudRenderResources(SerenityUiContext)

    Creates a resource bundle.

    Declaration
    public HudRenderResources(SerenityUiContext widgetContext)
    Parameters
    Type Name Description
    SerenityUiContext widgetContext

    The widget context to build themed elements from.

    Properties

    Style

    The theme's HUD visual language, or a built-in style when the theme carries none.

    Declaration
    public UnityUiThemeHudStyle Style { get; }
    Property Value
    Type Description
    UnityUiThemeHudStyle
    Remarks

    Never null, so a representation can read chrome unconditionally. A theme predating the style still yields a coherent HUD rather than each representation falling back to its own idea of a default.

    TextStyle

    The theme's own typeface and text colour, read from its buttons.

    Declaration
    public UiThemeTextStyle TextStyle { get; }
    Property Value
    Type Description
    UiThemeTextStyle
    Remarks

    Resolved once here, alongside the rest of the theme-derived building blocks, so an element that follows the theme does not walk the template prefab again for every text object it creates.

    Theme

    The active theme, or null when it is not available.

    Declaration
    public IUiThemeDefinition Theme { get; }
    Property Value
    Type Description
    IUiThemeDefinition

    WidgetContext

    The shared widget context, or null when Serenity has not finished booting.

    Declaration
    public SerenityUiContext WidgetContext { get; }
    Property Value
    Type Description
    SerenityUiContext

    Methods

    CreateText(RectTransform, string)

    Creates a text object for a HUD element under parent.

    Declaration
    public TMP_Text CreateText(RectTransform parent, string objectName)
    Parameters
    Type Name Description
    RectTransform parent

    The container to place the text under.

    string objectName

    Name for the created GameObject.

    Returns
    Type Description
    TMP_Text

    The text component to write into.

    Remarks

    Resolution mirrors the toast's: the theme's HUD template when it has one, otherwise the shared widget label, otherwise a bare TMP object. The HUD has to render before any theme has been retrofitted, so the last step is a genuine fallback rather than an error path.

    Deliberately does no styling. Font, colour and size are applied in one sweep once the element is fully built, because a representation may create several text objects and the element styles them as a unit — styling here as well meant every value was written twice, and every caller that had nothing to say had to invent a colour to pass in.

    In this article
    © 2026 Serenity. All Rights Reserved