Class UnityActivationApplier
Service that applies ActivationDelta on/off changes to Unity GameObjects. Analogous to UnityTransformApplier for transform scale.
Targets are registered with their TransformId and original activeSelf is cached. When Apply is called, each entry in the delta is resolved and applied.
Inherited Members
Namespace: Serenity.ProceduralAnimator.Infrastructure.Services
Assembly: Serenity.UnityProceduralAnimator.Infrastructure.dll
Syntax
public class UnityActivationApplier
Constructors
UnityActivationApplier()
Declaration
public UnityActivationApplier()
Properties
TargetCount
Gets the number of registered activation targets.
Declaration
public int TargetCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Apply(ActivationDelta)
Applies the activation delta to every registered target in a single self-correcting pass. For each target in Serenity.ProceduralAnimator.Infrastructure.Services.UnityActivationApplier._targets, resolves the desired active state — the delta's override for that target if present, otherwise the target's cached original active state — and issues exactly one guarded UnityEngine.GameObject.SetActive(System.Boolean) call when that desired state differs from the current UnityEngine.GameObject.activeSelf. Because every registered target is re-evaluated against its original state on every call, no separate per-tick reset is needed (or should be called) before this: a target no longer overridden by any layer's delta falls back to its original state on this very call, instead of paying for two SetActive calls (reset then override) in the same tick.
Declaration
public void Apply(ActivationDelta delta)
Parameters
| Type | Name | Description |
|---|---|---|
| ActivationDelta | delta | The activation delta containing this tick's on/off overrides. May be null or empty — in that case every target simply resolves to its cached original active state. |
ClearTargets()
Clears all registered activation targets. Restores every currently-tracked target to its cached original active state first, for the same reason UnregisterTarget(TransformId) does it for a single target — none of them will be re-evaluated once the dictionary is cleared.
Declaration
public void ClearTargets()
RegisterTarget(TransformId, GameObject)
Registers an activation target for procedural on/off animation. Caches the original activeSelf value for reset.
Declaration
public void RegisterTarget(TransformId id, GameObject gameObject)
Parameters
| Type | Name | Description |
|---|---|---|
| TransformId | id | Unique identifier for this activation target. |
| GameObject | gameObject | The GameObject to activate/deactivate. |
ResetToOriginalActive()
Resets all registered GameObjects to their cached original active state. No longer called
per-tick (see Apply(ActivationDelta), which is self-correcting and falls back to the original
state on its own) — this is for explicit/teardown use instead, e.g. component
OnDisable/OnDestroy, so nothing is left stuck toggled once the animator stops
running. Only calls UnityEngine.GameObject.SetActive(System.Boolean) when the current state actually
differs, for the same reason Apply(ActivationDelta) does.
Declaration
public void ResetToOriginalActive()
UnregisterTarget(TransformId)
Unregisters an activation target. Restores the target to its cached original active state first (single guarded UnityEngine.GameObject.SetActive(System.Boolean)) — once removed from Serenity.ProceduralAnimator.Infrastructure.Services.UnityActivationApplier._targets, nothing will ever re-evaluate this target again, so a target unregistered while overridden would otherwise stay stuck in the overridden state forever.
Declaration
public void UnregisterTarget(TransformId id)
Parameters
| Type | Name | Description |
|---|---|---|
| TransformId | id | The identifier of the target to unregister. |