Unity Menu Stack by bengreenier - 7


A way to track unity menu navigation that doesn't suck too much

Unity 5.5.1f1MIT LicenseUpdated 3 years agoCreated on February 28th, 2017
Go to source


A way to track unity menu navigation that doesn’t suck too much.


Managing the navigation of menu systems in unity is sucky. It shouldn’t be. unity-menustack provides simple menu state tracking behaviours.


See the generated docs (raw or hosted) for more info!


By default, prefixing is enabled, but it costs us perf. To disable it, set MenuRoot.DisableRuntimeTagging to true

Prefixing allows the building of menus given just GameObject names. At runtime, Menu or OverlayMenu components are added to facilitate the actual behaviours we expect.

You can tune which prefixes the system uses with MenuRoot.MenuPrefix and MenuRoot.OverlayPrefix.

Since this is enabled by default, you don’t need to worry about manually adding Menu or MenuOverlay components yourself.


  • Include Assets/Scripts in your project
  • Add a MenuRoot to some root level menu object
  • Prefix the name of all child menus with menu
  • Call this.GetComponentInParent<MenuRoot>().OpenAsync(Menu) or ``this.GetComponentInParent().CloseAsync()` from any submenu to navigate
  • [Optional] Listen for MenuRoot.Opened and MenuRoot.Closed events to know when things change


Overlays are regular menus, except they don’t hide the previous menu, they are displayed atop it

To use an overlay, simply prefix the name of a child menu with overlay.

Navigation provides wrappers around the MenuRoot.OpenAsync(Menu) and MenuRoot.CloseAsync() methods so you don’t have to!

See Assets/Examples/ComplexLayoutRigged.unity for an example.

That said, the general idea is as follows:

  • Add some INavigator to a component that should trigger navigation
  • Wire the trigger such that it calls INavigator.Navigate() (note: if the trigger is a button, it will be auto wired)
  • Configure additional properties of the specific INavigator you chose

Here’s a button that’s configured as a BackMenuNavigator:

screenshot backmenunav


Animation provides support for custom pretty 💃 transitions between menus!

See Assets/Examples/AnimatedLayoutRigged.unity for an example.

That said, the general idea is as follows:

  • Add a MenuAnimator to some Menu that you want to animate
  • This will add an Animator that you’ll need to setup
  • The Animator will need an AnimatorController, that you should define
  • The AnimatorController should define two states, one for open, and one for close - by default these are expected to be named Open and Close (though you can change that)
  • The AnimatorController should define two triggers, to enter each of these states - these must be named the same as the states
  • The AnimatorController should define transitions between the two states, and each trigger should be a condition
  • [Optional] you probably don’t want your animation clips to loop, so select them, and turn off looping in the inspector

This will make your menus transition from Close to Open when they open, and Open to Close when they close.

Hierarchy viewer

Hierarchy viewer is currently a beta feature, and should be treated as such!

The included Window/MenuStack/Hierarchy panel can be used to visualize the menustack and control visibility of different menus to make them easier to work with. When using this view, all history is tracked, and can be Reverted with the Reset button. Further, changes can be saved with the Save Button.

screenshot editorwindow


There’s a few examples under Assets/Examples. These should cover the major use cases and are fairly self explanatory. I’ll do some deep dive explanations in the near future.



Show all projects by bengreenier