Class HudDefinitionScanner
The single set of rules for whether an authored HUD will actually work: ids present and unique, bindings that still resolve, representations paired with a value they can render, and an update policy that fires.
Inherited Members
Namespace: Serenity.GameUi.Application.Validation
Assembly: Serenity.GameUi.Application.dll
Syntax
public static class HudDefinitionScanner
Remarks
Written once here because the same questions were being asked in three places that could not agree — the builder window's pre-write check, the project validator, and the drawer's inline hints. Every finding names the element and the group of fields it came from, which is what lets a tool turn a message into a link to its own cause rather than a sentence describing it.
Engine-agnostic and resolver-free: binding chains are checked by static reflection over member names, so no service has to be running. That is what lets the same rules run in the editor, in CI and in a pure test.
Fields
MaxChainWalkDepth
Depth cap for the parent-chain walk, so a malformed chain can never loop forever. Public: the Parent picker in the HUD Builder walks the same chain, over serialized data rather than IHudElementDefinition, to keep an element's own descendants off its own candidate list — it caps that walk at this exact value rather than a second, possibly-drifting constant.
Declaration
public const int MaxChainWalkDepth = 16
Field Value
| Type | Description |
|---|---|
| int |
Methods
ResolveWatchedElementId(IHudElementAnimationDefinition, IHudElementDefinition)
The element id an animation entry actually watches: its own authored WatchedElementId when
set, or the id of the element that authored it — the "empty means self" rule
WatchedElementId itself documents.
Declaration
public static string ResolveWatchedElementId(IHudElementAnimationDefinition animation, IHudElementDefinition element)
Parameters
| Type | Name | Description |
|---|---|---|
| IHudElementAnimationDefinition | animation | The animation entry. |
| IHudElementDefinition | element | The element that authored it. |
Returns
| Type | Description |
|---|---|
| string | The resolved watched element id. |
Remarks
Shared by this scanner's own duplicate-key check and, on the Unity side, hand-duplicated by the
Animation tab's watched-element picker (HudElementAnimationListGui.ResolvedWatchedElementId)
for GUI-only performance/decoupling reasons — one resolution rule, expressed twice because the
GUI's SerializedProperty-based row has no IHudElementDefinition to call this on
directly.
Scan(IHudDefinition, Func<IHudBinding, object>)
Scans a whole HUD, including every element in it.
Declaration
public static IReadOnlyList<AuthoringIssue> Scan(IHudDefinition hud, Func<IHudBinding, object> referenceResolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IHudDefinition | hud | The HUD to scan. |
| Func<IHudBinding, object> | referenceResolver | Supplies the directly-referenced source object for a binding, for the scene-object and asset source kinds. Omit it to scan without references, which is correct for a service-bound HUD. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<AuthoringIssue> | Every finding, asset-level first, then one element at a time in list order. |
Scan(string, IReadOnlyList<IHudElementDefinition>, Func<IHudBinding, object>)
Scans a HUD that has not been written yet, from the parts a builder holds while it is being authored.
Declaration
public static IReadOnlyList<AuthoringIssue> Scan(string hudId, IReadOnlyList<IHudElementDefinition> elements, Func<IHudBinding, object> referenceResolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | hudId | The id the HUD will be given. |
| IReadOnlyList<IHudElementDefinition> | elements | The elements it will hold. |
| Func<IHudBinding, object> | referenceResolver | Supplies the directly-referenced source object for a binding. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<AuthoringIssue> | Every finding, asset-level first, then one element at a time in list order. |
Remarks
The same rules as Scan(IHudDefinition, Func<IHudBinding, object>), reachable before there is an asset to pass. Without this the builder would have to keep its own copy of the rules, which is exactly how they came to disagree in the first place.
ScanElement(IHudElementDefinition, int, IReadOnlyList<IHudElementDefinition>, Func<IHudBinding, object>)
Scans one element with the whole HUD's element list available, so the cross-element animation rules — whether a named watched element exists on the HUD, and whether it can ever supply a value — run alongside every local rule the narrower overload already covers.
Declaration
public static IReadOnlyList<AuthoringIssue> ScanElement(IHudElementDefinition element, int index, IReadOnlyList<IHudElementDefinition> allElements, Func<IHudBinding, object> referenceResolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IHudElementDefinition | element | The element to scan. |
| int | index | Its position in the HUD's list. |
| IReadOnlyList<IHudElementDefinition> | allElements | Every element on the HUD, needed to resolve a named watched element by id. Pass null — or call ScanElement(IHudElementDefinition, int, Func<IHudBinding, object>) — when the full list is not available; the cross-element animation rules are simply skipped then. |
| Func<IHudBinding, object> | referenceResolver | Supplies the directly-referenced source object for a binding. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<AuthoringIssue> | Every finding about that element. |
ScanElement(IHudElementDefinition, int, Func<IHudBinding, object>)
Scans one element on its own, for a tool showing findings beside the element being edited.
Declaration
public static IReadOnlyList<AuthoringIssue> ScanElement(IHudElementDefinition element, int index, Func<IHudBinding, object> referenceResolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IHudElementDefinition | element | The element to scan. |
| int | index | Its position in the HUD's list. |
| Func<IHudBinding, object> | referenceResolver | Supplies the directly-referenced source object for a binding. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<AuthoringIssue> | Every finding about that element. |
Remarks
Cross-element animation rules — whether a named watched element exists, and whether it can ever supply a value — need the whole HUD's element list and are skipped here. Call ScanElement(IHudElementDefinition, int, IReadOnlyList<IHudElementDefinition>, Func<IHudBinding, object>) with that list when those rules should run too.