public static void Hide()
 {
     if (window != null)
     {
         window.Close();
         window = null;
     }
 }
        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, ValidateCallback callback)
        {
            //Close window if already open
            if (window != null)
            {
                Hide();
                return;
            }

            //Open window
            DeletePopup.callback = callback;
            window = CreateInstance <DeletePopup>();
            window.ShowPopup();
            window.minSize      = new Vector2(100, 90);
            window.titleContent = new GUIContent("ChoicePopup");
            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();
 }