void DropdownOnClicked() { var menu = new GenericMenu(); OverlayPresetManager.GenerateMenu(menu, "", m_Canvas.containerWindow); menu.DropDown(m_Dropdown.worldBound); }
void OnGUI() { GUILayout.Space(5); Event evt = Event.current; bool hitEnter = evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter); bool hitEscape = evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Escape); if (hitEscape) { Close(); GUIUtility.ExitGUI(); } GUI.SetNextControlName("m_PreferencesName"); EditorGUI.BeginChangeCheck(); m_PresetName = EditorGUILayout.TextField(m_PresetName); m_PresetName = m_PresetName.TrimEnd(); if (EditorGUI.EndChangeCheck()) { UpdateCurrentInvalidChars(); } if (!m_DidFocus) { m_DidFocus = true; EditorGUI.FocusTextInControl("m_PreferencesName"); } if (m_CurrentInvalidChars.Length != 0) { EditorGUILayout.HelpBox(string.Format(s_InvalidCharsFormatString, m_CurrentInvalidChars), MessageType.Warning); minSize = new Vector2(k_Width, k_Height + k_HelpBoxHeight); } else { minSize = new Vector2(k_Width, k_Height); } bool canSaveLayout = m_PresetName.Length > 0 && m_CurrentInvalidChars.Length == 0; EditorGUI.BeginDisabled(!canSaveLayout); if (GUILayout.Button("Save") || hitEnter && canSaveLayout) { Close(); if (OverlayPresetManager.Exists(m_Window.GetType(), m_PresetName)) { if (!EditorUtility.DisplayDialog("Overwrite preset?", "Do you want to overwrite '" + m_PresetName + "' preset?", "Overwrite", "Cancel")) { GUIUtility.ExitGUI(); } } save(m_PresetName); GUIUtility.ExitGUI(); } else { m_DidFocus = false; } EditorGUI.EndDisabled(); }