How to Trigger a Transition by Label

You can also trigger a transition by the label you assigned to it. Labels do not need to be unique, which means that you can have multiple transitions with the same label. When triggering a transition by its label, the State Machine will trigger the first transition it finds, which has the given label and can be triggered from the currently active state. This behaviour ca be useful when you want to implement a return button for your UI or e.g. a restart option after the game is won or lost.

To trigger a transition by label you can simply call:

  • TriggerByLabel(string label)

  • TryTriggerByLabel(string label)

Last updated