StateMachine<TKey, TState>.

InitializeAfterDeserialize() Method

Summary

Call this after deserializing to properly initialize the Animancer.FSM.StateMachine`1.CurrentState.
Assembly
Animancer.dll
Namespace
Animancer.FSM
Containing Type
StateMachine<TKey, TState>

Syntax

public override void InitializeAfterDeserialize()

Remarks

Unfortunately, UnityEngine.ISerializationCallbackReceiver can't be used to automate this because many Unity functions aren't available during serialization such as getting or setting a UnityEngine.Behaviour.enabled like Animancer.FSM.StateBehaviour.OnEnterState does.

Example:
public class MyComponent : MonoBehaviour
{
    [SerializeField]
    private StateMachine<MyState> _StateMachine;
    
    protected virtual void Awake()
    {
        _StateMachine.InitializeAfterDeserialize();
    }
}

Return Value

Type Description
void