Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

StateMachineChanges

class in Unity.GraphToolkit.Editor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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

Properties

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.