logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class HudElementHierarchy

    Assembles a built HUD's parent/child element tree on top of the flat build every host runs first.

    Inheritance
    object
    HudElementHierarchy
    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.Views
    Assembly: Serenity.UnityGameUi.Infrastructure.dll
    Syntax
    public static class HudElementHierarchy
    Remarks

    Two passes over the same flat list UnityHudHostComponent.BuildElements and HudPreviewBuilder.Build already produce, so a FLEXBOX box's children need no special construction order of their own — every element is built once, independently, exactly as it is today; this only reparents the ones that authored a ParentId and then settles the resulting layout. Called from both the runtime host and the editor preview builder, so the game and the preview can never disagree about where a parented element ends up.

    Reparenting a child also strips its own UnityEngine.UI.ContentSizeFitter — every element's container gets one from UnityHudElementView.ApplyGrowLayout, and left in place it fights the parent box's layout group: Unity runs the parent's group first (which, with childControlWidth/Height on, would size the child to its FIXED/PERCENT/FLEX share, or read its AUTO preferred size), then the child's own fitter runs as a self-controller on the same rect and overwrites that with its own preferred size — silently zeroing FLEX growth and defeating a box-wide Align.STRETCH. Removing it is safe: the child's own UnityEngine.UI.HorizontalOrVerticalLayoutGroup (also added by ApplyGrowLayout) is itself an ILayoutElement that reports its preferred size from its own children, which is exactly what the parent's group reads for an AUTO child once the fitter is no longer there to fight it.

    Methods

    Build(IReadOnlyList<UnityHudElementView>, IReadOnlyList<UnityHudElementDefinition>)

    Reparents every element with an authored ParentId under its parent's content root, sizes it along the parent's main axis when a size was authored, then forces one layout rebuild per root-level box so the whole tree settles before the frame is read.

    Declaration
    public static void Build(IReadOnlyList<UnityHudElementView> views, IReadOnlyList<UnityHudElementDefinition> definitions)
    Parameters
    Type Name Description
    IReadOnlyList<UnityHudElementView> views

    The already-built views, in the same order as definitions.

    IReadOnlyList<UnityHudElementDefinition> definitions

    The authored definitions the views were built from.

    In this article
    © 2026 Serenity. All Rights Reserved