Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

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.

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

ContextVisualization context that produced the current state reference.
FillAmountThe progress fill amount displayed on the referenced state's accent bar, expressed as a percentage.
StateIDUnique identifier of the state this reference points to.

Methods

Method

Description

ClearCustomizationClears all customization previously applied to the referenced state, removes any fill amount, and stops any looping animation.
EqualsIndicates whether the current StateReference is equal to another object.
GetHashCodeReturns a hash code for the current StateReference.

Operators

Operator

Description

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