Skip to main content
Flow Core Documentation
Menu

Stack

Composing Logic with Stacks

Layer temporary modes and restore the previous mode with explicit push and pop lifecycle.

Audience
Gameplay and UI developers
Time
12 minutes
Requires
A last-in, first-out mode requirement
Modules
Stack
On this page

Use Stack when a temporary layer covers the current mode and the previous mode must resume after the layer is removed. Typical uses include nested menus, dialogue input, inspect mode, and tutorial overlays.

Mental model

Stack Root owns the ordered collection. Stack Layer is the item that can be pushed.

Only the top layer receives Update. A layer below it remains paused until every layer above it is popped.

Lifecycle outputMeaning
PushThe layer is added to the stack.
ResumeThe layer becomes the active top layer.
UpdateThe current top layer receives its configured update.
PauseThe layer stops being top.
PopThe layer is removed.

Build a UI stack

  1. Add a Stack Root and name it UiStack.
  2. Configure the root’s Update Interrupt policy.
  3. Add Stack Layers named Gameplay, PauseMenu, and Options, then configure each layer’s update interval.
  4. Set every layer’s Root Name to UiStack.
  5. Put show or enable work in Resume.
  6. Put hide or disable work in Pause.
  7. Put one-time setup and cleanup in Push and Pop.
  8. Enable unique layers when a screen must not be pushed twice.

Select a layer in the graph, then edit its lifecycle Instruction sections in the Flow Inspector or Node Editor. Single Focus keeps the active entry and its owning section open. Choose Continuous to compare Resume with Pause, or use Expand All Items temporarily and then Return to Entry Expansion Mode. These view choices do not push, pause, resume, or pop a runtime layer. See Node Inspector & Entry Editing.

A live Graph shows complete Gameplay, PauseMenu and Options push, pop and resume routes; a separate UiStack editor crop shows Options active and Stack Size 3.

Gameplay, PauseMenu and Options appear left to right after being pushed in that order. The separate UiStack status crop below shows Options active and Stack Size 3. Every Layer exposes Push, Resume, Update, Pause and Pop ports; the shown Resume routes lead to visible log Actions.

Expected runtime order:

Gameplay active
Push PauseMenu -> Gameplay pauses, PauseMenu resumes
Push Options   -> PauseMenu pauses, Options resumes
Pop Options    -> Options exits, PauseMenu resumes
Pop PauseMenu  -> PauseMenu exits, Gameplay resumes

When Stack is not the owner

Do not use Stack when two systems should update concurrently. Independent movement and upper-body state families are better expressed as separate FSM groups or processes. Do not use Stack merely because several nodes form a list.

Root and layer names are runtime relationships. Keep them stable and add comments around cross-process pushes so target ownership remains visible.

Common mistakes

SymptomCheck
A layer never joins the stackIts Root Name must match the Stack Root title.
Lower layers keep updatingConfirm their work is connected to the layer Update lifecycle rather than a separate Trigger.
The same menu appears twiceEnable unique layers where duplicates are invalid.
Push waits unexpectedlyCheck the root’s Update interruption mode and active Update work.
Two concurrent systems block each otherThey should not share one last-in, first-out stack.