/// <summary> /// Creates and opens an Add Component Menu Window that rolls open below or above unrollPosition. /// </summary> /// <param name="setInspector"> The inspector which is opening the menu. </param> /// <param name="items"> Root items of the menu. </param> /// <param name="groupsByLabel"> All groups in the menu flattened, with full label path of group as key in dictionary. </param> /// <param name="itemsByLabel"> All non-group leaf items in the menu flattened, with full label path of item as key in dictionary. </param> /// <param name="tickedItems"> items that are ticked in the menu. </param> /// <param name="canTickMultipleItems"> Is it possible to have mutliple items ticked in the menu simultaneously? </param> /// <param name="unrollPosition"> The position above or below which the menu should open. </param> /// <param name="onMenuItemClicked"> Action to invoke when a menu item is clicked. </param> /// <param name="onClosed"> Action to invoke when the menu is closed. </param> /// <param name="menuTitle"> Title for menu. </param> public static void Create([NotNull] IInspector setInspector, [NotNull] List <PopupMenuItem> items, [NotNull] Dictionary <string, PopupMenuItem> groupsByLabel, [NotNull] Dictionary <string, PopupMenuItem> itemsByLabel, [CanBeNull] List <PopupMenuItem> tickedItems, bool canTickMultipleItems, Rect unrollPosition, Action <PopupMenuItem> onMenuItemClicked, Action onClosed, GUIContent menuTitle) { if (instance != null) { instance.Setup(setInspector, items, groupsByLabel, itemsByLabel, tickedItems, unrollPosition, onMenuItemClicked, onClosed, menuTitle, canTickMultipleItems); return; } instance = CreateInstance <PopupMenuWindow>(); instance.Setup(setInspector, items, groupsByLabel, itemsByLabel, tickedItems, unrollPosition, onMenuItemClicked, onClosed, menuTitle, canTickMultipleItems); }
private void Dispose() { if (instance != null) { instance = null; if (drawer != null) { #if DEV_MODE && PI_ASSERTATIONS Debug.Assert(drawer.OnCurrentViewItemCountChanged.GetInvocationList().Length == 1, "PopupMenuWindow.OnCurrentViewItemCountChanged.Length != 1: " + StringUtils.ToString(drawer.OnCurrentViewItemCountChanged)); #endif drawer.OnCurrentViewItemCountChanged = null; drawer.OnClosed(); } if (onClosed != null) { var callback = onClosed; onClosed = null; callback(); } } }