Skip to main content
Interact with the Rive State Machine in Unity. For more information on Rive State Machines see the respective runtime and editor documentation.

Overview

A StateMachine advances (plays) animations in an Artboard.
  • Components
  • Legacy API
A Rive Widget automatically loads and advances the state machine from your artboard configuration settings. Here’s how you can access the loaded state machine in your scripts:
[SerializeField] private RiveWidget m_riveWidget;

...

void OnEnable()
{
    m_riveWidget.OnWidgetStatusChanged += OnWidgetStatusChanged;
}

private void OnWidgetStatusChanged()
{
    // Wait for the Rive Widget to load before accessing the state machine.
    if (m_riveWidget.Status == WidgetStatus.Loaded)
    {
        StateMachine m_stateMachine = m_riveWidget.StateMachine;
    }
}


void OnDisable()
{
    m_riveWidget.OnWidgetStatusChanged -= OnWidgetStatusChanged;
}
I