public static MultiSelectItem[] DropDown(MultiSelectItem[] items, string value, string callerId) { if (items == null || items.Length == 0) { return(items); } if (popupWindow != null && callerId == popupWindow.OwnerId) { items = popupWindow.GetItemsAndClose(); if (!popupWindow) { popupWindow = null; } } var popupSize = GetPopupDimensions(items.Select(item => item.Name), value); GUILayout.Box(value, GUILayout.Width(popupSize.x)); var popupPosition = GUIUtility.GUIToScreenPoint(GUILayoutUtility.GetLastRect().position); if (GUILayout.Button(ExpandDownButtonText, GUILayout.Width(24f)) && EnsurePopupWindow()) { popupWindow.Show(callerId, items, popupPosition, popupSize); } return(items); }
private static bool EnsurePopupWindow() { if (popupWindow != null) { return(true); } var modTools = GameObject.FindObjectOfType <MainWindow>(); if (modTools == null) { return(false); } if (modTools.GetComponent <MultiPopupWindow>() == null) { popupWindow = modTools.gameObject.AddComponent <MultiPopupWindow>(); } return(popupWindow != null); }