logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class ProceduralAnimatorComponent

    Main MonoBehaviour that drives the procedural animation system. Evaluates rules, computes layer weights, manages action lifecycle, and applies the combined pose delta to the rig.

    Inheritance
    object
    ProceduralAnimatorComponent
    Namespace: Serenity.ProceduralAnimator.Infrastructure.Components
    Assembly: Serenity.UnityProceduralAnimator.Infrastructure.dll
    Syntax
    public class ProceduralAnimatorComponent : MonoBehaviour
    Remarks

    Intentionally Unity-only: this is a MonoBehaviour orchestrator driven by Unity's Update/LateUpdate lifecycle and SerializeField-configured arrays. It is the Unity-side composition of the other (now-ported) pieces, analogous to other "intentionally Unity-only" orchestrator components already documented in the codebase — no Business port for v1.

    Constructors

    ProceduralAnimatorComponent()

    Declaration
    public ProceduralAnimatorComponent()

    Properties

    DrivesRig

    Gets or sets whether this animator drives an assigned rig via pose deltas. See the 'Drives Rig' tooltip on the serialized field. Settable, alongside UseProfileConfiguration and UpdateMode, so code assembling a non-rig animator entirely at runtime — e.g. a HUD host's shared ProceduralAnimator player, with no scene-authored value to fall back on — can flip it right after UnityEngine.Component.gameObject.AddComponent, before EnsureInitialized() runs.

    Declaration
    public bool DrivesRig { get; set; }
    Property Value
    Type Description
    bool

    MaterialApplier

    Gets the material applier for advanced configuration. Use RegisterMaterialTarget/UnregisterMaterialTarget for basic usage.

    Declaration
    public UnityMaterialApplier MaterialApplier { get; }
    Property Value
    Type Description
    UnityMaterialApplier

    Profile

    Gets the profile used for auto-configuration.

    Declaration
    public ProceduralAnimatorProfileSO Profile { get; }
    Property Value
    Type Description
    ProceduralAnimatorProfileSO

    RigDefinition

    Gets the rig definition (resolved from component or profile).

    Declaration
    public UnityRigDefinition RigDefinition { get; }
    Property Value
    Type Description
    UnityRigDefinition

    StateBus

    Gets the state bus component.

    Declaration
    public StateBusComponent StateBus { get; }
    Property Value
    Type Description
    StateBusComponent

    UpdateMode

    Gets or sets when this animator ticks itself. Set to Manual so an external host can drive Tick(float, float) with its own clock instead.

    Declaration
    public UpdateMode UpdateMode { get; set; }
    Property Value
    Type Description
    UpdateMode

    UseProfileConfiguration

    Gets or sets whether to use Profile configuration instead of local arrays.

    Declaration
    public bool UseProfileConfiguration { get; set; }
    Property Value
    Type Description
    bool

    Methods

    ActivateLayer(ProceduralLayerSO)

    Activates a layer for one-shot/repeating ON_ACTIVATE playback: snaps its blend weight straight to 1, deliberately skipping the normal blend-in ramp so the sequence's own step easing owns the motion shape. Re-activating an already-active layer restarts its sequence from the top on the next evaluated frame. No-op for a layer this animator isn't tracking (i.e. not part of its Profile/local layers or ConfigureRuntimeLayers(IReadOnlyList<ProceduralLayerSO>, bool)).

    Declaration
    public void ActivateLayer(ProceduralLayerSO layer)
    Parameters
    Type Name Description
    ProceduralLayerSO layer

    ClearExcludedBones()

    Clears the excluded-bone set, so every bone resumes being driven by the procedural pipeline.

    Declaration
    public void ClearExcludedBones()

    ConfigureRuntimeLayers(IReadOnlyList<ProceduralLayerSO>, bool)

    Registers layers at runtime without going through a Profile asset — e.g. a non-rig animator (see DrivesRig) assembled entirely in code. Layers not already part of this animator's effective layer set are appended to it and start tracking weight.

    Declaration
    public void ConfigureRuntimeLayers(IReadOnlyList<ProceduralLayerSO> layers, bool startInactive)
    Parameters
    Type Name Description
    IReadOnlyList<ProceduralLayerSO> layers

    The layers to register. Null entries are ignored. A layer already tracked — Profile-authored or from a prior ConfigureRuntimeLayers(IReadOnlyList<ProceduralLayerSO>, bool) call — is skipped without touching its current weight.

    bool startInactive

    When true, each newly-registered layer's weight starts at 0 instead of Serenity.ProceduralAnimator.Infrastructure.Components.ProceduralAnimatorComponent.Initialize's usual "no controlling rule defaults to weight 1" behavior — so the layer stays silent until an explicit ActivateLayer(ProceduralLayerSO) call, instead of firing immediately on registration.

    DeactivateLayer(ProceduralLayerSO)

    Deactivates a layer: snaps its blend weight straight to 0 (no blend-out ramp, mirroring ActivateLayer(ProceduralLayerSO)) and removes its activation stamp. Also happens on its own once an ON_ACTIVATE layer's repeat count elapses. No-op for a layer this animator isn't tracking.

    Declaration
    public void DeactivateLayer(ProceduralLayerSO layer)
    Parameters
    Type Name Description
    ProceduralLayerSO layer

    EnsureInitialized()

    Runs the one-time setup Serenity.ProceduralAnimator.Infrastructure.Components.ProceduralAnimatorComponent.Start performs, if it has not run yet. Idempotent, so edit-mode tooling can prepare a component Unity never sent Start to.

    Declaration
    public void EnsureInitialized()

    GetLayerWeight(ProceduralLayerSO)

    Gets the current weight of a layer.

    Declaration
    public float GetLayerWeight(ProceduralLayerSO layer)
    Parameters
    Type Name Description
    ProceduralLayerSO layer
    Returns
    Type Description
    float

    ReRegisterMaterialTargetsFromProfile()

    Re-registers all material targets from the profile. Call this if materials or shaders are changed at runtime (e.g., Rendering Mode changes). Clears existing targets and re-registers from profile.

    Declaration
    public void ReRegisterMaterialTargetsFromProfile()

    RecacheBasePose()

    Re-caches the base pose. Call this if the rig's default pose changes at runtime.

    Declaration
    public void RecacheBasePose()

    RecachePositionBaselines()

    Forwards to RecachePositionBaselines(): re-derives every DRIVEN position target's baseline against its current live local position, undoing only the offset this animator's own applier last wrote (not a plain re-cache — see that method's own remarks for why the distinction matters).

    Declaration
    public void RecachePositionBaselines()
    Remarks

    Call this after something OTHER than this animator moves a driven target's parent/anchors between two Tick(float, float) calls in the same frame — e.g. UnityHudHostComponent.ApplySafeAreaIfChanged shifting the HUD root's rect before this component's Tick(float, float) runs. Without this call, the next Tick would apply this frame's offset against the STALE pre-move baseline, snapping a driven root element back to where it sat before the external move instead of tracking it.

    RegisterActivationTarget(string, GameObject)

    Registers an activation target for procedural on/off animation at runtime, without going through the Profile's Transform Targets list.

    Declaration
    public void RegisterActivationTarget(string id, GameObject go)
    Parameters
    Type Name Description
    string id

    Unique identifier for this activation target.

    GameObject go

    The GameObject to activate/deactivate.

    RegisterMaterialTarget(string, Renderer, int)

    Registers a material target for procedural material animation. Must be called for each material that layers will animate. Uses automatic property detection for the specified material slot.

    Declaration
    public void RegisterMaterialTarget(string materialId, Renderer renderer, int materialIndex = 0)
    Parameters
    Type Name Description
    string materialId

    Unique identifier for this material target.

    Renderer renderer

    The renderer to animate.

    int materialIndex

    Material slot index (0 for first material).

    RegisterTransformTarget(string, Transform, bool)

    Registers a transform target for procedural transform-scale/rotation/position animation at runtime, without going through the Profile's Transform Targets list.

    Declaration
    public void RegisterTransformTarget(string id, Transform t, bool allowPositionOverride)
    Parameters
    Type Name Description
    string id

    Unique identifier for this transform target.

    Transform t

    The transform to animate.

    bool allowPositionOverride

    Whether this target accepts position-channel animation — forwarded to RegisterTarget(TransformId, Transform, bool). No default: every caller must decide explicitly, since position is layout-hostile for a FLEXBOX-parented HUD element (see TransformDelta's own remarks) — UnityHudHostComponent.BuildAnimator passes true only for a root-level element (no ParentId); every other caller should pass false.

    RegisterUiColorTarget(string, RectTransform, Func<Transform, bool>)

    Registers a UiColor target for procedural UGUI Graphic tint/fade animation at runtime — e.g. a HUD element's content root.

    Declaration
    public void RegisterUiColorTarget(string id, RectTransform root, Func<Transform, bool> isForeignElementRoot)
    Parameters
    Type Name Description
    string id

    Unique identifier for this target — a HUD element id.

    RectTransform root

    The content root to collect own Graphics under.

    Func<Transform, bool> isForeignElementRoot

    Returns true for a descendant transform marking a DIFFERENT element's own root, so a reparented sibling's Graphics are never collected as this target's own — forwarded verbatim to RegisterTarget(TransformId, RectTransform, Func<Transform, bool>). Pass null when there is no such boundary to respect (e.g. a non-HUD caller with no reparenting concept).

    ResetAllLayerWeights()

    Resets all layer weights to zero, dropping every ON_ACTIVATE activation stamp along with them — otherwise a layer silenced this way would keep its stale activation time, so a later direct SetLayerWeight(ProceduralLayerSO, float) call (bypassing ActivateLayer(ProceduralLayerSO)) would resume mid-sequence instead of at layer-local time zero.

    Declaration
    public void ResetAllLayerWeights()

    SetExcludedBones(IEnumerable<string>)

    Excludes the given bone ids from the procedural pose pipeline from the next Tick(float, float) onward — e.g. handing limb bones off to ragdoll physics on death. Replaces any previously excluded set (not additive). Pass an empty/null sequence, or call ClearExcludedBones(), to resume driving every bone.

    Declaration
    public void SetExcludedBones(IEnumerable<string> boneIds)
    Parameters
    Type Name Description
    IEnumerable<string> boneIds

    SetLayerWeight(ProceduralLayerSO, float)

    Manually sets a layer's target weight.

    Declaration
    public void SetLayerWeight(ProceduralLayerSO layer, float weight)
    Parameters
    Type Name Description
    ProceduralLayerSO layer
    float weight

    StopAllActions()

    Stops all active actions immediately.

    Declaration
    public void StopAllActions()

    Tick(float, float)

    Runs one evaluation frame against an explicitly supplied clock instead of UnityEngine.Time. The Update/LateUpdate path calls this with the engine clock; edit-mode tooling drives it with its own accumulated time so the whole rule/layer/action pipeline runs without entering Play mode.

    Declaration
    public void Tick(float time, float deltaTime)
    Parameters
    Type Name Description
    float time
    float deltaTime

    TriggerAction(ProceduralActionSO)

    Manually triggers an action by reference.

    Declaration
    public void TriggerAction(ProceduralActionSO action)
    Parameters
    Type Name Description
    ProceduralActionSO action

    UnregisterActivationTarget(string)

    Unregisters an activation target registered via RegisterActivationTarget(string, GameObject).

    Declaration
    public void UnregisterActivationTarget(string id)
    Parameters
    Type Name Description
    string id

    The identifier of the activation target to unregister.

    UnregisterMaterialTarget(string)

    Unregisters a material target.

    Declaration
    public void UnregisterMaterialTarget(string materialId)
    Parameters
    Type Name Description
    string materialId

    The identifier of the material target to unregister.

    UnregisterTransformTarget(string)

    Unregisters a transform target registered via RegisterTransformTarget(string, Transform, bool).

    Declaration
    public void UnregisterTransformTarget(string id)
    Parameters
    Type Name Description
    string id

    The identifier of the transform target to unregister.

    UnregisterUiColorTarget(string)

    Unregisters a UiColor target registered via RegisterUiColorTarget(string, RectTransform, Func<Transform, bool>).

    Declaration
    public void UnregisterUiColorTarget(string id)
    Parameters
    Type Name Description
    string id

    The identifier of the UiColor target to unregister.

    In this article
    © 2026 Serenity. All Rights Reserved