logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class HudElementRootMarker

    Marks a GameObject as one HUD element's own root container, so code walking a built HUD's hierarchy can tell where one element ends and another begins — most importantly once a FLEXBOX box has reparented a child element underneath it.

    Inheritance
    object
    HudElementRootMarker
    Namespace: Serenity.GameUi.Infrastructure.Views
    Assembly: Serenity.UnityGameUi.Infrastructure.dll
    Syntax
    public sealed class HudElementRootMarker : MonoBehaviour
    Remarks

    Carries no data of its own; its presence is the whole signal. Serenity.GameUi.Infrastructure.Views.UnityHudElementView.ApplyTextStyle(UnityEngine.RectTransform,Serenity.GameUi.Infrastructure.Settings.UnityHudElementDefinition,Serenity.GameUi.Infrastructure.Representations.HudRenderResources) is what actually reads it: its typeface/colour sweep stops descending the moment it meets a nested marker, so a parent box can never re-style a reparented child's text out from under it.

    Today ApplyTextStyle runs exactly once per element, inside Construct, strictly before HudElementHierarchy ever reparents anything — no path in this codebase re-styles an already-built HUD (there is no theme hot-reload or live-restyle trigger for it), so the guard has nothing to catch yet. It stays in place as intentional hardening for whichever re-entrant styling path is added first — a theme change applied live, or a settings-driven restyle — so that path is correct against nested elements from the moment it exists, rather than needing this guard bolted on retroactively once someone discovers a parent box can re-stomp a reparented child's typography.

    Constructors

    HudElementRootMarker()

    Declaration
    public HudElementRootMarker()

    Methods

    MarksForeignRoot(Transform)

    Whether candidate carries this marker — true for a DIFFERENT HUD element's own (possibly reparented) root, false otherwise. The single boundary predicate every own-component walk that must stop at a nested element's root passes to CollectOwn<T>(Transform, Transform, List<T>, Func<Transform, bool>): UnityHudElementView.CollectOwnText (own text styling) and UnityHudHostComponent.BuildAnimator (UiColor Graphic collection registration) both construct their walk with this method rather than each keeping its own hand-copied predicate — three identical one-line lambdas used to exist across this class's callers and the test suite before they were unified here.

    Declaration
    public static bool MarksForeignRoot(Transform candidate)
    Parameters
    Type Name Description
    Transform candidate

    The transform to test.

    Returns
    Type Description
    bool
    In this article
    © 2026 Serenity. All Rights Reserved