Skip to content

A menu system for Unity projects. Create complex menus without writing a single line of code

License

Notifications You must be signed in to change notification settings

hfjooste/MenuBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Menu Builder for Unity

License

You are free to do whatever you want with this library. You're allowed to use this for commercial projects, edit the source code and even redistribute the source code. No attribution is required (but appreciated)

Requirements

  • Unity 2020.3.11f1
  • Unity Input System

Features

This tool allows you to create complex menus without writing a single line of code. It includes to following features

  1. Keyboard and controller support using the Unity Input System
  2. Vertical, Horizontal and Tabbed style menus
  3. Wrap-around when exceeding the start/end positions
  4. Activated, deactivated, selected and canceled events that can be handled inside the editor

Setting up the input

Input System This library includes demo input actions that should be perfect for any game. If you want to create your own, you can follow these steps:

  1. Right click in the project and select Create > Input Actions
  2. Use InputActions as the name
  3. Open the new Input Actions file
  4. Create a new control scheme
  5. Create a Menu Action Map
  6. Create the following actions:
    • Vertical (1D Axis)
    • Horizontal (1D Axis composite)
    • Tabs (1D Axis composite)
    • Select (Button binding)
    • Cancel (Button binding)
  7. Specify the key bindings for each action

Please refer to the official Unity documentation for more information: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/QuickStartGuide.html

Default input

Action Keyboard Controller
Navigate Up Up Arrow
W Key
Left Stick Up
D-Pad Up
Navigate Down Down Arrow
S Key
Left Stick Down
D-Pad Down
Navigate Left Left Arrow
A Key
Left Stick Left
D-Pad Left
Navigate Right Right Arrow
D Key
Left Stick Right
D-Pad Right
Tab Previous Q Key
Page Down
Left Trigger
Tab Next E Key
Page Up
Right Trigger
Select Enter Key South Button
Cancel/Back Escape Key East Button

Handling input inside the scene

Menu Input

  1. Add a new empty game object to your scene
  2. Add a Menu Input component to this new game object

This Menu Input component will read the input from the Unity Input System (using the InputActions file) and invoke the correct events when needed

Creating a menu

Menu

  1. Add a new empty game object to your scene
  2. Add a Menu component to this new game object
  3. Set the properties of the menu
    • Active: A boolean value indicating if the menu can receive input events
    • Menu Style: The type of menu you're using (Vertical, Horizontal or Tabbed)
    • Reset Index After Loading: Reset the selected index after loading the menu (or disabling and enabling it)
    • Wrap Around: Enable/disable the wrap-around feature when exceeding the start/end position of the menu
    • Menu Items: A list of all menu items managed by this menu
  4. Set up the canceled event (optional)

Creating a menu item

Menu Item

  1. Add a new empty game object to your scene
  2. Add a Menu Item component to this new game object
  3. Set up the activated event (optional). This is invoked when the menu item is active
  4. Set up the deactivated event (optional). This is invoked when the menu item is deactivated
  5. Set up the selected event (optional). This is invoked when the menu item is selected
  6. Design the menu item

Remember to add the menu item to the menu. Otherwise no events will be invoked

Creating input indicators

Menu Indicators

  1. Add a new empty game object to your scene
  2. Add a Menu Device Monitor component to this new game object
  3. Create device indicators for all the controllers/input devices you support
  4. Specify all the device indicators in the Menu Device Monitor component

The Menu Device Monitor requires an instance of Menu Input in the same scene

Demo

Demo Scene This library includes a demo scene that shows you how to create vertical, horizontal and tabbed menus. It also includes different menus using different features available in the library (including device/input indicators). There's a Input directory that contains an InputActions file that should be perfect for your game

About

A menu system for Unity projects. Create complex menus without writing a single line of code

Resources

License

Stars

Watchers

Forks

Languages