CreateVariable
Creates and adds a new variable to the state machine.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: Unity.GraphToolkit.Editor
- Assembly: UnityEditor
CreateVariable(string, Type, Object, VariableKind)
Creates and adds a new variable to the state machine.
public IVariable CreateVariable(string name, Type valueType, object defaultValue = null, VariableKind kind = VariableKind.Local)
Parameters
The name of the variable.
The data type of the variable.
The default value. Must be compatible with and work with Unity serialization rules for SerializeField.
valueTypeThe kind of variable, defined by VariableKind.
Returns
Type | Description |
|---|---|
| IVariable | The newly created variable. |
Remarks
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.
CreateVariable<T>(string, T, VariableKind)
Creates and adds a new variable to the state machine.
public IVariable CreateVariable<T>(string name, T defaultValue = default, VariableKind kind = VariableKind.Local)
Parameters
Returns
Type | Description |
|---|---|
| IVariable | The newly created variable. |
Remarks
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.