Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


State

The base class for all user-accessible states in a State.StateMachine.
Read time 2 minutesLast updated 6 days ago

Definition

public abstract class State : IState

Remarks

Inherit from this class to define custom state types that appear in a state machine graph. A state represents a node in a State.StateMachine; transitions connect states to one another. Unlike Node, a state does not expose configurable input and output ports: its incoming and outgoing transition connections are managed by the state machine itself.
See also:
  • State.StateMachine for the graph type that contains states
  • Node for the equivalent base class used in regular graphs
  • IState for the interface this class implements

Properties

Property

Description

DefaultColorThe highlight color of the state. The highlight is located on the upper border of the state.
FillAmountThe progress fill amount displayed on the state's accent bar, expressed as a percentage.
IDThe globally unique identifier for this state.
IsConnectedWhether the state is connected to at least one transition.
OptionCountThe number of options defined in the state.
OptionsThe options defined on this state.
PositionThe position of the state in the state machine.
StateMachineThe State.StateMachine that contains this state.
SubtitleThe secondary text displayed in the state's header.
TitleThe main text displayed in the state's header.
TooltipThe text displayed when hovering over the state's header.

Methods

Method

Description

DefineStateDefines the structure of the state by building its options.
GetIncomingTransitionsRetrieves the transitions that go to this state.
GetOptionRetrieves a state option using its zero-based index.
GetOptionByNameRetrieves a state option using its name.
GetOutgoingTransitionsRetrieves the transitions that originate from this state.
OnDefineOptionsCalled during State.DefineState to define the options available on the state.
OnDisableCalled when the state is removed or when the state machine is disabled.
OnEnableCalled when the state is created or when the state machine is enabled.
RemoveFromStateMachineRemoves the state from its state machine.

Interfaces

Interface

Description

State.IOptionDefinitionContextInterface that provides methods to declare state options inside a state.