Class HudElementTreeOrder
Orders a HUD's elements for tree-style display: each FLEXBOX box's children directly beneath it, in the same array order a flat list would already show them in, recursively.
Inherited Members
Namespace: Serenity.GameUi.Application.Authoring
Assembly: Serenity.GameUi.Application.dll
Syntax
public static class HudElementTreeOrder
Remarks
Pure and engine-agnostic — no SerializedProperty, no UnityHudElementDefinition — so the same
solver drives both editor consumers (the inspector's HudElementListGui and the wizard's
CreateHudWindow) through the HudElementTreeOrderGui adapter, and is testable without Unity.
A dangling or cyclic parent reference is already a validator finding on its own account (see HudDefinitionScanner); this solver's own job is only to never lose a row over one — a malformed chain surfaces as a root at depth 0 instead of vanishing from the list, which is what makes Solve(IReadOnlyList<Node>) always return a permutation of every input index.
Cycle detection (Serenity.GameUi.Application.Authoring.HudElementTreeOrder.ComputeCyclic(System.Int32[])) and the display depth cap are two DELIBERATELY separate concerns. Cycle detection is a proper O(n) functional-graph walk with no length limit of its own, so a tail chain of any length hanging off a cycle is promoted exactly as reliably as a one-hop tail — a per-node walk capped at a hop count would let a sufficiently long tail slip through with a false "not cyclic" the moment its hop budget ran out before reaching the repeat. MaxChainWalkDepth only clamps the reported Depth (and, correspondingly, how far a legitimately deep but non-cyclic chain visually indents) — it plays no part in deciding what is a root.
Fields
NoSibling
Sentinel meaning "there is no sibling on that side", and "this row has no resolved parent".
Declaration
public const int NoSibling = -1
Field Value
| Type | Description |
|---|---|
| int |
Methods
Solve(IReadOnlyList<Node>)
Solves the display order: roots first in array order, each node's children directly beneath it in array order, recursively.
Declaration
public static IReadOnlyList<HudElementTreeOrder.Row> Solve(IReadOnlyList<HudElementTreeOrder.Node> nodes)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<HudElementTreeOrder.Node> | nodes | Every element, in the HUD's own authored order. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<HudElementTreeOrder.Row> | One row per node, in display order. |
Remarks
A node is a root when its ParentId is empty, names no other node (dangling), names itself, or sits in — or its chain leads into — a cycle of parent references: every one of those cases surfaces the node at depth 0 instead of dropping it, which is what guarantees the result is always a permutation of every input index. A tail node hanging off a cycle is promoted right along with the cycle itself, consistently, regardless of how many hops separate it from the actual repeat — see Serenity.GameUi.Application.Authoring.HudElementTreeOrder.ComputeCyclic(System.Int32[]). Duplicate ids resolve first-match, the same rule HudDefinitionScanner's own hierarchy scan uses.