private static void SearchablePopup(Rect rect, string label, int selectedIndex, string[] displayedOptions, Action <string> onSelected) { StatelessAdvancedDropdown.ResetAndCreateWindow(); StatelessAdvancedDropdown.InitWindow(rect, label, selectedIndex, displayedOptions); StatelessAdvancedDropdown.s_Instance.onSelected += delegate(AdvancedDropdownWindow w) { onSelected(w.GetIdOfSelectedItem()); }; }
public static int SearchablePopup(Rect rect, int selectedIndex, string[] displayedOptions, GUIStyle style) { string text = null; if (selectedIndex >= 0) { text = displayedOptions[selectedIndex]; } GUIContent gUIContent = new GUIContent(text); int controlID = GUIUtility.GetControlID("AdvancedDropdown".GetHashCode(), FocusType.Keyboard, rect); if (EditorGUI.DropdownButton(controlID, rect, gUIContent, "MiniPullDown")) { StatelessAdvancedDropdown.s_CurrentControl = controlID; StatelessAdvancedDropdown.ResetAndCreateWindow(); StatelessAdvancedDropdown.InitWindow(rect, gUIContent.text, selectedIndex, displayedOptions); StatelessAdvancedDropdown.s_Instance.onSelected += delegate(AdvancedDropdownWindow w) { StatelessAdvancedDropdown.m_Result = w.GetSelectedIndex(); StatelessAdvancedDropdown.m_WindowClosed = true; }; } int result; if (StatelessAdvancedDropdown.m_WindowClosed && StatelessAdvancedDropdown.s_CurrentControl == controlID) { StatelessAdvancedDropdown.s_CurrentControl = 0; StatelessAdvancedDropdown.m_WindowClosed = false; result = StatelessAdvancedDropdown.m_Result; } else { result = selectedIndex; } return(result); }