StateFlow is a visual state machine for Unity UI. Lay out every screen, popup and alert on one canvas, wire them together with type-safe triggers, and watch the flow run live while you play.
Add a Trigger event to a state's script and it appears on the node as an output port. Drag it onto another state and that's the transition. No string IDs, no hand-written switch statements.
A Trigger<LevelData> can only connect to a state that accepts LevelData, so a wrong connection never makes it into your game.
In play mode, the transition that fired last carries a running marker and a chip showing the value it passed. Here, Level Select just started Level 12 · Hard.
Group related states into a sub-state machine and it collapses to a single node. Its entry and exit states show up as ports on the parent graph. Double-click to open it, and use the breadcrumb to step back out.
A connection drops or an achievement unlocks, and it doesn't matter which screen is showing. Global trigger nodes stay live the whole time. Fire one from anywhere with one static call and route it to an alert or a toast.
Toasts sit outside the screen stack, with their own position, animation (Drop, Raise, Slide, or your own) and duration. You set all of it right in the graph.
Press Play and the graph comes alive. The active state lights up, the last transition animates, and its payload is right there on the wire. Turn on Follow and the view keeps the active state in frame. If that state is inside a sub-state, the view keeps the sub-state's node in frame.
Here the player just solved a level. Board fired Solved<LevelResult>, and Level Complete is now active with 3★ · 12,480 pts.
Plain C#. No code generation, no magic strings.
Derive from StateFlowComponent and declare a Trigger event for each way out of the screen.
Drop in a prefab, or use a script for logic-only states. Then choose its layer and mark the entry and exit states.
Drag from port to port. A StateFlowManager in your scene runs the asset, loading states through Resources or Addressables.
public class LevelSelectPresenter : StateFlowComponent { public event Trigger<LevelData> StartLevel; // port: StartLevel<LevelData> public event Trigger Back; // port: Back } public class BoardPresenter : StateFlowComponent, IStateFlowComponentWithPayload<LevelData> { [SpawnedState, SerializeField] private BoosterBar boosterBar; // its triggers show on this node too public event Trigger<LevelResult> Solved; public event Trigger Pause; public void SetPayload(LevelData level) { /* build the board */ } } // App-wide events, raised from anywhere AppEvents.RaiseConnectionLost();
Write your own transition class to animate between any two states, with underlay and overlay layers to work with.
Every state gets Initialize, Enter, TransitionFinished, Exit and Dispose, so set-up and clean-up always run in a predictable order.
If a prefab loses a component or a trigger gets renamed, the broken transitions show up in a panel instead of failing quietly.
StateFlow runs the screens in every TravelBug game, and soon you'll be able to use it in your own Unity projects too.
Read the documentation →