Logo
UI Elements

Menu Bar

A row of buttons that open context menus

Overview

Menu Bar builds a set of menu buttons and connects each one to a Context Menu. It can regenerate its items in Edit Mode as well as at runtime.

Preview

Usage

Add the Menu Bar component to a UI object or create a Menu Bar prefab via Evo UI -> Create.

Populate Items, including each label and context-menu content.

Assign the button and context-menu presets.

Enable Open Menu On Hover if menus should respond to pointer hover.


Customization

  • Edit the item preset for button appearance and the context-menu preset for menu layout and animation.
  • Item Menu Offset positions each menu relative to its button.

Public API

Use MenuBar in the Evo.UI namespace.

Call Refresh() after editing the item list. Generated views are available through each item’s GeneratedButton and GeneratedMenu.

Properties

NameTypeDescription
IsOpenboolWhether a bar item has an open menu.

Fields

NameTypeDescription
itemsList<Item>MenuBar.Item definitions.
openMenuOnHoverboolEnables hover opening.
blockUIWhileOpenboolBlocks other UI while a menu is open.

Methods

NameParametersDescription
Refresh()NoneGenerates or refreshes the menu buttons.
OpenMenu()Item targetItemOpens the specified Item.
CloseMenu()NoneCloses the active menu.
GetItem()string labelFinds an Item by its label. Returns Item.

Example

MenuBarExample.cs
using UnityEngine;
using Evo.UI;

public class MenuBarExample : MonoBehaviour
{
    [SerializeField] private MenuBar target;

    private void Start()
    {
        target.Refresh();
        var fileMenu = target.GetItem("File");
        if (fileMenu != null)
            target.OpenMenu(fileMenu);
    }
}

On this page