Disconnect(IState, IState)
Removes all transitions that go from one state to another.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Method
- Namespace: Unity.GraphToolkit.Editor
- Assembly: UnityEditor
public bool Disconnect(IState fromState, IState toState)
Parameters
Returns
Type | Description |
|---|---|
| bool | |
Remarks
Only transitions that leave and enter are removed; transitions in the opposite direction are left untouched. When and are the same state, self transitions on that state are removed, together with all the rules they hold. To remove a single rule and keep the transition, use ITransition.RemoveRule instead. Enclose this method with StateMachine.UndoBeginRecordStateMachine and StateMachine.UndoEndRecordStateMachine to add this operation to the undo stack and to update the graph view with the changes. Throws ArgumentNullException when or is . Throws ArgumentException when either state does not belong to this state machine.
fromStatetoStatefromStatetoStatefromStatetoStatenullAdditional Resources: StateMachine.GetTransitions, StateMachine.Connect
The following example removes every transition that goes from one state to another.
Examples
void ClearTransitions(StateMachine stateMachine, IState idle, IState patrol){ stateMachine.UndoBeginRecordStateMachine("Clear transitions"); // Removes all Idle -> Patrol transitions, and returns true if there was at least one. // Patrol -> Idle transitions are left untouched. stateMachine.Disconnect(idle, patrol); // Removes the self transition on Patrol, with all the rules it holds. stateMachine.Disconnect(patrol, patrol); stateMachine.UndoEndRecordStateMachine();}