public DropdownMenuAction FindMenuAction(string name) { foreach (var menuItem in mMenu.MenuItems()) { if (menuItem is DropdownMenuAction menuAction) { if (menuAction.name == name) { return(menuAction); } } } return(null); }
public void Setup() { m_Instance = new CopyAllTheFields(); m_Menu = new DropdownMenu(); m_Menu.AddCopyValue(m_Instance); m_Actions = m_Menu.MenuItems().OfType <DropdownMenuAction>().ToArray(); }
public static void ShowMenu(this VisualElement visualElement, DropdownMenu menu) { if (visualElement != null && menu != null && menu.MenuItems().Any()) { Vector2 p = new Vector2(visualElement.layout.xMin, visualElement.layout.yMax); p = visualElement.parent.LocalToWorld(p); menu.DoDisplayEditorMenu(p); } }
public void UpdateMenu() { var menu = new DropdownMenu(); EditorApplication.delayCall -= UpdateMenu; if (m_Enabled && m_Total == 0) { EditorApplication.delayCall += UpdateMenu; } AddDropdownItems(menu); loadAssetsDropdown.menu = menu.MenuItems().Count > 0 ? menu : null; }
// Start is called before the first frame update void Start() { CampaignList = new Serializer <List <Campaign> >().Deserialize(Application.persistentDataPath + "/Data/Campaigns/campaignList.xml"); //Campaigns.ClearOptions(); Campaigns.MenuItems().Clear(); foreach (Campaign aCampaign in CampaignList) { Dropdown.OptionData currCampaign = new Dropdown.OptionData(); currCampaign.text = aCampaign.Name; Campaigns.options.Add(currCampaign); } Campaigns.value = 0; Campaigns.RefreshShownValue(); Campaigns.onValueChanged.AddListener((value) => UpdateFactions(value)); UpdateFactions(0); }
private void Build(DropdownMenu menu) { rootMenu?.ReturnToPool(); rootMenu = subMenuPool.GetPooled(); blockingLayer.Add(rootMenu); foreach (var item in menu.MenuItems()) { if (item is DropdownMenuSeparator s) { rootMenu.AddItem(item, s.subMenuPath.Split('/'), 0); } else if (item is DropdownMenuAction a) { rootMenu.AddItem(item, a.name.Split('/'), 0); } } }
static GenericMenu PrepareMenu(DropdownMenu menu, EventBase triggerEvent) { menu.PrepareForDisplay(triggerEvent); var genericMenu = new GenericMenu(); foreach (var item in menu.MenuItems()) { var action = item as DropdownMenuAction; if (action != null) { if ((action.status & DropdownMenuAction.Status.Hidden) == DropdownMenuAction.Status.Hidden || action.status == 0) { continue; } bool isChecked = (action.status & DropdownMenuAction.Status.Checked) == DropdownMenuAction.Status.Checked; if ((action.status & DropdownMenuAction.Status.Disabled) == DropdownMenuAction.Status.Disabled) { genericMenu.AddDisabledItem(new GUIContent(action.name), isChecked); } else { genericMenu.AddItem(new GUIContent(action.name), isChecked, () => { action.Execute(); }); } } else { var separator = item as DropdownMenuSeparator; if (separator != null) { genericMenu.AddSeparator(separator.subMenuPath); } } } return(genericMenu); }
private static GenericMenu PrepareMenu(DropdownMenu menu, EventBase triggerEvent) { menu.PrepareForDisplay(triggerEvent); GenericMenu genericMenu = new GenericMenu(); foreach (DropdownMenuItem item in menu.MenuItems()) { DropdownMenuAction action = item as DropdownMenuAction; if (action != null) { if ((action.status & DropdownMenuAction.Status.Hidden) != DropdownMenuAction.Status.Hidden && action.status != 0) { bool on = (action.status & DropdownMenuAction.Status.Checked) == DropdownMenuAction.Status.Checked; if ((action.status & DropdownMenuAction.Status.Disabled) == DropdownMenuAction.Status.Disabled) { genericMenu.AddDisabledItem(new GUIContent(action.name), on); } else { genericMenu.AddItem(new GUIContent(action.name), on, delegate { action.Execute(); }); } } } else { DropdownMenuSeparator dropdownMenuSeparator = item as DropdownMenuSeparator; if (dropdownMenuSeparator != null) { genericMenu.AddSeparator(dropdownMenuSeparator.subMenuPath); } } } return(genericMenu); }
protected internal override void DoDisplayMenu(DropdownMenu menu, EventBase triggerEvent) { menuIsDisplayed = true; menuItemCount = menu.MenuItems().Count; mMenu = menu; }