Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


StateMachineChanges

The set of changes to a state machine reported to StateMachine.OnStateMachineChanged in a single change event.
Read time 1 minuteLast updated 10 days ago

Definition

public class StateMachineChanges

Remarks

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.

Examples

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}");}

Properties

Property

Description

ChangedStatesThe states that were added or modified in this change event.
ChangedSubgraphStatesThe subgraph states that were added or modified in this change event.
ChangedTransitionsThe transitions that were added or modified in this change event.
ChangedVariablesThe variables that were added or modified in this change event.