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();
        }