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

StateReference

struct in Unity.GraphToolkit.Editor.GraphVisualization

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

Identifies a state inside a visualization StateReference.Context so visualization changes can be applied to it.

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

 // 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.

Public 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 StateReference.
GetHashCode Returns a hash code for the current StateReference.

Operators

Operator Description
operator != Compares two StateReference values for inequality.
operator == Compares two StateReference values for equality.