StateReference
Identifies a state inside a visualization StateReference.Context so visualization changes can be applied to it.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Struct
- Namespace: Unity.GraphToolkit.Editor.GraphVisualization
- Assembly: UnityEditor
- Implements: IEquatable<StateReference>
public readonly struct StateReference : IEquatable<StateReference>
Remarks
Obtain a StateReference from Context.GetStateReference. The reference is only meaningful for the StateReference.Context that produced it. You can use its properties to set, retrieve, or clear customization for that specific state in the state machine canvas. Two StateReference values are equal when they share the same StateReference.StateID and refer to the same StateReference.Context instance.
Additional Resources: StateReference.Context, Context.GetStateReference
Examples
// Obtain a reference to a state by its ID, then drive its visual state.using Context context = Registry.CreateVisualizationContext(stateMachineID);StateReference stateRef = context.GetStateReference(stateID);// Show a half-filled accent bar on the state.stateRef.FillAmount = 50f;// Replace the static fill with a looping progress animation.context.Motion.Play(stateRef, animationSpeed: 1f);// Stop the animation. The bar remains visible at the previously set fill amount.context.Motion.Stop(stateRef);
Properties
Property | Description |
|---|---|
| Context | Visualization context that produced the current state reference. |
| FillAmount | The progress fill amount displayed on the referenced state's accent bar, expressed as a percentage. |
| StateID | Unique identifier of the state this reference points to. |
Methods
Method | Description |
|---|---|
| ClearCustomization | Clears all customization previously applied to the referenced state, removes any fill amount, and stops any looping animation. |
| Equals | Indicates whether the current StateReference is equal to another object. |
| GetHashCode | Returns a hash code for the current StateReference. |
Operators
Operator | Description |
|---|---|
| operator == | Compares two StateReference values for equality. |
| operator != | Compares two StateReference values for inequality. |