MenuView-Package in Unity: Simple Menu Management Tool

This is my simple UnityGameEngine menu management tool and I want to share it with my friends. You can Create some Menus and switch between them and manage them at multiple layers.

Introduction

Managing menus efficiently in Unity can be challenging, especially when dealing with a single scene. To simplify this process, I created MenuView-Package, a simple and effective menu management tool for Unity Game Engine. With this tool, you can create menus, switch between them quickly using button functions, and manage them across different layers effortlessly.

Why I Created MenuView-Package

When developing games in Unity, I often found handling menus within a single scene to be cumbersome. Unity’s built-in UI management system requires manual toggling of GameObjects and tracking menu states, which can lead to unstructured and inefficient code.

I created MenuView-Package to:

  • Provide a structured and simple way to manage menus within a single scene.
  • Allow developers to switch between menus instantly via button functions.
  • Offer a reusable and scalable approach to menu navigation.
  • Reduce the need for manual UI state tracking.

With MenuView-Package, handling menus within a single scene becomes seamless, making it easier to maintain and extend UI systems in Unity projects.

What It Does & How It Simplifies Menu Handling

MenuView-Package provides an efficient way to create and manage multiple menus in Unity. It allows you to:

  • Create menus easily by inheriting from MenuView.
  • Switch between menus dynamically with simple commands.
  • Manage menus across multiple layers, ensuring structured navigation.
  • Avoid redundant UI state management, as the package keeps track of the last active view.
  • Call functions in UI buttons to switch menus rapidly without extra logic.

By handling menu navigation programmatically, this tool significantly reduces UI-related complexity and ensures a smoother development process.

Getting Started

Using MenuView-Package is straightforward. Follow these steps to integrate it into your Unity project:

1. Importing the Package

To use MenuView-Package, you need to import it via the Unity Package Manager:

  • Open Unity Package Manager.
  • Select Add package from git URL: MenuView-Package
  • Enter the package URL and import it into your project.

2. Creating a Menu Script

Each menu in your game should be defined as a script inheriting from MenuView. Here’s how you can set up your menu scripts:

Example 1: Main Game Menu

Create a script named MainGameMenu.cs and inherit from MenuView instead of MonoBehaviour.

using MenuViews;

public class MainGameMenu : MenuView
{
    protected override void Init()
    {
        // Initialize buttons, texts, events, and more
        throw new System.NotImplementedException();
    }
    
    // Available commands:
    // ChangeCurrentView<AuthMenu>();
    // ChangeToLastView();
    // LastView { get; }
    // GetCurrentView();
}

Example 2: Authentication Menu

Similarly, create another menu script for authentication, like AuthMenu.cs:

using MenuViews;

public class AuthMenu : MenuView
{
    protected override void Init()
    {
        throw new System.NotImplementedException();
    }
}

Example 3: Settings Menu

Another common menu is a settings menu. Here’s how you can create one:

using MenuViews;

public class SettingsMenu : MenuView
{
    protected override void Init()
    {
        // Initialize settings options here
    }
}

Example 4: Pause Menu

A pause menu can be added in a similar way:

using MenuViews;

public class PauseMenu : MenuView
{
    protected override void Init()
    {
        // Initialize pause menu options here
    }
}

Managing Menus

Once your menus are set up, you can manage them using various commands:

  • ChangeCurrentView<T>() - Switch to a specific menu view.
  • ChangeToLastView() - Return to the previous menu.
  • LastView - Retrieve the last active menu.
  • GetCurrentView() - Get the currently active menu.
  • CloseThisView() - Close the current menu.
  • CloseAll() - Close all menus in the current layer.

How to Use in UI Buttons

One of the key features of this package is the ability to call functions in UI buttons to switch menus easily. Here’s how you can do it:

  1. Attach a Button component to your UI button.
  2. In the OnClick() event of the button, add a function call like:
    • MainGameMenu.ChangeCurrentView<AuthMenu>();
    • AuthMenu.ChangeToLastView();

This makes switching between menus fast and seamless without writing extra logic.

Why Use MenuView-Package?

  • Easy to integrate – Just import the package and modify your menu scripts.
  • Simplifies menu switching – No need for complex UI state management.
  • Supports multiple UI layers – Useful for games with deep menu structures.
  • Works within a single scene – No need for scene transitions for menu changes.
  • Reduces development time – Provides a streamlined approach to menu navigation.

Conclusion

MenuView-Package is a lightweight and powerful tool to handle UI menus in Unity seamlessly. Whether you’re building a simple game or a complex application, this tool can help streamline your UI navigation. Feel free to try it out and share your feedback!

 

This article was updated on May 5, 2025
Hooman Jalalpoor

Hooman Jalalpoor

Hi, I’m Hooman Jalalpoor—an Indie Game Programmer, Software Engineer, and Generative Artist. With a deep passion for creating immersive and artistic games, I specialize in game development using Unity and C#, as well as crafting unique generative art and NFTs.

My journey in game development has been driven by a love for storytelling, creativity, and innovation. I’ve participated in numerous game jams, where my team and I created award-winning games like Impasse, Balls of Chaos, and Shattered. These experiences have honed my skills in game design, team collaboration, and rapid prototyping.

Beyond games, I’ve explored the intersection of art and technology by producing generative artworks and NFTs, leveraging tools like JavaScript and p5.js. My work in this space has not only allowed me to express my creativity but also to understand the dynamics of the digital art market.

I hold a Master’s degree in Computer Software Engineering, where I focused on neural networks and blockchain technology for cryptocurrency price prediction. This academic background has equipped me with a strong foundation in machine learning, optimization, and research, which I often integrate into my projects.

Currently, I serve as the Manager of the Academy of Technical Experiences, where I oversee program development and foster a learning environment for aspiring technical professionals. This role has allowed me to grow as a leader while sharing my knowledge with others.

I’m also passionate about education and have created game-making tutorials in Persian to help aspiring developers in my community. Although this venture was cut short, I hope to continue creating educational content in the future.

When I’m not coding or designing games, you’ll find me exploring new technologies, experimenting with procedural art, or brainstorming ideas for my next project. My ultimate goal is to create games and experiences that resonate with players on an emotional and artistic level.

Let’s connect and create something amazing together!