public static void Hide()
 {
     if (window != null)
     {
         window.Close();
         window = null;
     }
 }
 public void Rename()
 {
     StringPopup.Show(GUIUtility.GUIToScreenRect(renameRect.Offset(0, 20, 0, 0)),
                      "Rename clip", clip.clipName, (string value) => {
         if (!string.IsNullOrEmpty(clip.clipName) && value != clip.clipName)
         {
             Rename(value);
         }
     });
 }
        public override void OnInspectorGUI()
        {
            //Init vars
            Event e = Event.current;

            mousePosition = e.mousePosition;

            //Speech properties
            GUILayout.Space(10);
            DrawSpeechProperties();
            GUILayout.Space(10);


            //Select a voice box
            bool noVoice = string.IsNullOrEmpty(speech.voiceUUID);

            if (noVoice)
            {
                EditorGUILayout.HelpBox("Please select a voice.", MessageType.Info);
            }


            //Disable ui if there is no voice selecteds
            EditorGUI.BeginDisabledGroup(noVoice);


            //Rebuild list if needed and draw it
            if (list == null)
            {
                RebuildClipList();
            }
            list.DoLayoutList();


            //Draw commands buttons
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(list.index < 0);
            deleteButton.DoLayout((Rect r) => { HidePopups(); DeletePopup.Show(r, DeleteClip); });
            EditorGUI.EndDisabledGroup();
            importButton.DoLayout((Rect r) => { HidePopups(); ClipPopup.Show(r, speech, ImportClip); });
            CreateButton.DoLayout((Rect r) => { HidePopups(); StringPopup.Show(r, "New clip name", CreateClip); });
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();


            //Draw connected error
            Utils.ConnectionRequireMessage();


            //Keep a constant refresh
            Repaint();
        }
        public static void Show(Rect rect, string title, string value, ValidateCallback callback)
        {
            //Close window if already open
            if (window != null)
            {
                Hide();
                return;
            }

            //Open window
            StringPopup.value      = value;
            StringPopup.fieldTitle = title;
            StringPopup.callback   = callback;
            window = CreateInstance <StringPopup>();
            window.ShowPopup();
            window.minSize      = new Vector2(100, 70);
            window.titleContent = new GUIContent("StringFieldPopup");
            window.position     = rect;
        }
 /// <summary> Ensures that all popup windows that the editor can open are closed. </summary>
 private void HidePopups()
 {
     DeletePopup.Hide();
     ClipPopup.Hide();
     StringPopup.Hide();
 }