Class HudElementOwnComponentCollector
Generic recursive walk that collects every component of type T under a root
transform, stopping the descent the moment it meets a nested "foreign root" boundary — e.g. a different,
possibly-reparented HUD element's own root.
Inherited Members
Namespace: Serenity.ProceduralAnimator.Infrastructure.Services
Assembly: Serenity.UnityProceduralAnimator.Infrastructure.dll
Syntax
public static class HudElementOwnComponentCollector
Remarks
Extracted from UnityHudElementView.CollectOwnText's original walk — that method's own text-only
version now forwards here — so UnityGraphicColorApplier (which needs the exact same "stop at a
foreign element's root" walk, but collecting Graphic instead of TMP_Text) shares one
implementation instead of a second hand-copied recursion.
Why this lives here, not next to UnityHudElementView in GameUi's own assembly:
Serenity.UnityGameUi.Infrastructure already depends on Serenity.UnityProceduralAnimator.Infrastructure
(every HUD element animation type comes from there), and UnityGraphicColorApplier — which needs
this exact walk — lives in the latter assembly alongside ProceduralAnimatorComponent, which owns
it. Placing this collector in GameUi's assembly instead would need
Serenity.UnityProceduralAnimator.Infrastructure to reference GameUi's assembly to reach it —
exactly backwards from the dependency direction that already exists, and Unity does not allow a circular
assembly reference. Making the boundary check a caller-supplied predicate (isForeignRoot
on CollectOwn<T>(Transform, Transform, List<T>, Func<Transform, bool>)) rather than hard-coding a check against GameUi's own
HudElementRootMarker type is what makes that possible: this class needs no GameUi type at all, so it
can sit on the shared (lower) side of that dependency and be called from either direction.
Methods
CollectOwn<T>(Transform, Transform, List<T>, Func<Transform, bool>)
Collects every T under current that still belongs to
root's own element — everything Transform.GetComponentsInChildren<T>()
would find, minus whatever sits under a nested foreign-root boundary.
Declaration
public static void CollectOwn<T>(Transform root, Transform current, List<T> results, Func<Transform, bool> isForeignRoot) where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | root | The element's own root — the boundary |
| Transform | current | The transform whose children are being walked this call (starts equal to |
| List<T> | results | Collected components are appended here, in traversal order. |
| Func<Transform, bool> | isForeignRoot | Returns true for a descendant transform that marks a DIFFERENT element's own root — the walk does not descend past it. Must not be null. |
Type Parameters
| Name | Description |
|---|---|
| T | The component type to collect. |
Remarks
root itself is never treated as a boundary against itself — only a DESCENDANT
transform for which isForeignRoot returns true stops the walk from going further
down that branch. Plain recursion over UnityEngine.Transform.GetChild(System.Int32) rather than LINQ or
GetComponentsInChildren, to keep the boundary check able to short-circuit a whole branch rather
than filtering a flat list after the fact.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|