private void Toolbar() { GUIExtensions.Toolbar(new Vector2(MENU_BUTTON_SPACING, MENU_BUTTON_SPACING), menus.Select(x => x.name).ToArray(), (index, rect) => { if (menus[index].menuType == MenuType.Action) { menus[index].action?.Invoke(); activeMenu = -1; // Disable all menus ActionOnRecursiveMenuItems(menus, x => { // Don't change the value of windows if (x.menuItems.Count > 0) { x.enabled = false; } }); } else if (menus[index].menuType == MenuType.Window) { menus[index].enabled = !menus[index].enabled; activeMenu = -1; // Disable all menus ActionOnRecursiveMenuItems(menus, x => { // Don't change the value of windows if (x.menuItems.Count > 0) { x.enabled = false; } }); } else { // Toggle the menu menus[index].enabled = !menus[index].enabled; // Select the active menu if (!menus[index].enabled) { activeMenu = -1; } else { activeMenu = index; } // Set the alignment for top level sub menus menus[index].alignment = rect.x; // Disable any current menus in this menu if (activeMenu >= 0) { ActionOnRecursiveMenuItems(menus, x => { // Don't disable the current menu - toggle it below // Don't change the value of windows if (x != menus[activeMenu] && x.menuItems.Count > 0) { x.enabled = false; } }); } } }); }