The set of changes to a state machine reported to StateMachine.OnStateMachineChanged in a single change event.
Access this through StateMachineLogger.StateMachineChanges inside
StateMachine.OnStateMachineChanged. Inspect StateMachineChanges.ChangedStates,
StateMachineChanges.ChangedTransitions, StateMachineChanges.ChangedVariables, and StateMachineChanges.ChangedSubgraphStates to
react to what was added or modified. Each entry's ChangeKinds property is a set of
ChangeKind bit-flags describing the categories of change that apply.
public override void OnStateMachineChanged(StateMachineLogger stateMachineLogger) { StateMachineChanges changes = stateMachineLogger.StateMachineChanges;
foreach (ChangedState changedState in changes.ChangedStates) { if ((changedState.ChangeKinds & ChangeKind.Added) != 0) Debug.Log($"State added: {changedState.State.Title}");
if ((changedState.ChangeKinds & ChangeKind.Topology) != 0 && !changedState.State.IsConnected) stateMachineLogger.LogWarning("This state has no transitions.", changedState.State); }
foreach (ChangedTransition changedTransition in changes.ChangedTransitions) { // Rule and condition edits arrive as ChangeKind.Data on the owning transition. if ((changedTransition.ChangeKinds & ChangeKind.Data) == 0) continue;
foreach (ITransitionRule rule in changedTransition.Transition.GetRules()) Debug.Log($"Rule updated: {rule.Title}"); }
foreach (ChangedVariable changedVariable in changes.ChangedVariables) Debug.Log($"Variable changed: {changedVariable.Variable.Name} ({changedVariable.ChangeKinds})");
foreach (ChangedSubgraphState changedSubgraphState in changes.ChangedSubgraphStates) Debug.Log($"Subgraph state changed: {changedSubgraphState.SubgraphState.Title}"); }
| Property | Description |
|---|---|
| ChangedStates | The states that were added or modified in this change event. |
| ChangedSubgraphStates | The subgraph states that were added or modified in this change event. |
| ChangedTransitions | The transitions that were added or modified in this change event. |
| ChangedVariables | The variables that were added or modified in this change event. |