Skip to main content
DEPRECATION NOTICE: This entire page documents the legacy system. For new projects: Use Data Binding instead. For existing projects: Plan to migrate from to Data Binding as soon as possible. This content is provided for legacy support only.

Accessing Inputs

There are three input types, each extends SMIInput (State Machine Input):
  • SMIBool contains a .Value property, a boolean that can be set to true or false.
  • SMITrigger is a boolean that is set to true for one frame by calling the .Fire() method.
  • SMINumber contains a .Value property, a float that can be set to any value.
State machine inputs can be accessed in a number of different ways.

Access by name

Retrieve a state machine input by name and type. Trigger:
SMITrigger someTrigger = m_stateMachine.GetTrigger("icon_02_press_trig");
if (someTrigger != null)
{
    someTrigger.Fire();
}
Bool:
SMIBool someBool = m_stateMachine.GetBool("centerHover");
if (someBool == null) return;
Debug.Log(someBool.Value);
someBool.Value = !someBool.Value;
Debug.Log(someBool.Value);
Number:
SMINumber someNumber = m_stateMachine.GetNumber("rating");
if (someNumber == null) return;
Debug.Log(someNumber.Value);
someNumber.Value = 4;
Debug.Log(someNumber.Value);

Access by index

Get the input count (length) and retrieve by index:
Debug.Log(m_stateMachine.InputCount());
SMIInput input = m_stateMachine.Input(1);

Access all inputs

Retrieve a list of all SMIInputs:
var inputs = m_riveStateMachine.Inputs();
foreach (var input in inputs)
{
    switch (input)
    {
        case SMITrigger smiTrigger:
        {
            // Do something
            break;
        }
        case SMIBool smiBool:
        {
            // Do something
            break;
        }
        case SMINumber smiNumber:
        {
            // Do something
            break;
        }
    }
}

Accessing Nested Inputs

For more information about accessing inputs in components, check out this example.

Additional Resources

For a complete example see the getting-started project in the examples repository and open the StateMachineInputScene scene. Enter Play mode and in the inspector on the Main Camera component, you can interact with all available state machine inputs for the provided animation.
I