private void DrawAudioArea()
        {
            //Remove request if completed
            if (request != null && request.status == AsyncRequest.Status.Completed)
            {
                request = null;
            }

            //Draw pending message or dowload progress bar
            if (request != null && !request.isDone)
            {
                if (request.status != AsyncRequest.Status.Downloading)
                {
                    GUILayout.Space(4);
                    Utils.DrawPendingLabel("Pending...");
                    GUILayout.Space(-10);
                    Utils.DrawSeparator();
                    GUILayout.Space(-5);
                }
                else
                {
                    GUILayout.Space(10);
                    Rect  rect     = GUILayoutUtility.GetRect(Screen.width, 30);
                    float progress = request.downloadProgress;
                    EditorGUI.ProgressBar(rect, progress, "Download : " + Mathf.RoundToInt(progress * 100) + "%");
                }
            }

            //Draw Audio preview
            else if (clip.clip != null)
            {
                DrawAudioPlayer();
            }

            //Draw commands
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (request != null)
            {
                if (GUILayout.Button("Show pending list"))
                {
                    Resemble_Window.Open(Resemble_Window.Tab.Pool);
                }
                if (clip.clip != null && GUILayout.Button("Select placeholder"))
                {
                    EditorGUIUtility.PingObject(clip.clip);
                    Selection.activeObject = clip.clip;
                }
            }
            else if (clip.clip != null)
            {
                if (GUILayout.Button("Select file"))
                {
                    EditorGUIUtility.PingObject(clip.clip);
                    Selection.activeObject = clip.clip;
                }
            }
            GUILayout.EndHorizontal();
        }
        private void DrawSpeechProperties()
        {
            //Voice field
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Voice", GUILayout.Width(EditorGUIUtility.labelWidth - 2));
            if (EditorGUILayout.DropdownButton(new GUIContent(string.IsNullOrEmpty(speech.voiceName) ? "None" : speech.voiceName), FocusType.Passive))
            {
                VoicePopup.Show(voiceRect, (Voice voice) =>
                {
                    speech.voiceName = voice.name;
                    speech.voiceUUID = voice.uuid;
                    EditorUtility.SetDirty(speech);
                });
            }

            //Set rect for popup
            if (Event.current.type == EventType.Repaint)
            {
                voiceRect = GUIUtility.GUIToScreenRect(GUILayoutUtility.GetLastRect().Offset(0, 18, 0, 100));
            }
            EditorGUILayout.EndHorizontal();

            //Begin Change Check
            EditorGUI.BeginChangeCheck();

            //Include phonemes
            speech.includePhonemes = EditorGUILayout.Toggle("Include phonemes", speech.includePhonemes);

            //Phoneme table
            if (speech.includePhonemes)
            {
                PhonemeTable temp = EditorGUILayout.ObjectField(phonemeTableLabel, speech.phonemeTable, typeof(PhonemeTable), false) as PhonemeTable;

                //Update phoneme table on clip when change
                if (temp != speech.phonemeTable)
                {
                    speech.phonemeTable = temp;
                    for (int i = 0; i < speech.clips.Count; i++)
                    {
                        if (speech.clips[i].havePhonemes)
                        {
                            speech.clips[i].phonemes.UpdateTable(temp);
                        }
                    }
                }
            }

            //Apply change if any
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(speech);
            }

            GUILayout.Space(5);
            Utils.DrawSeparator();
        }
        private void DrawOptionsSettingsGUI()
        {
            //Path settings
            GUILayout.Label(new GUIContent("Paths", "Describe where AudioClips from CharacterSets should be generated."), Styles.header);

            //Path methode
            Settings.pathMethode = (Settings.PathMethode)EditorGUILayout.EnumPopup(
                pathMethode, Settings.pathMethode);

            //Target folders fields
            switch (Settings.pathMethode)
            {
            case Settings.PathMethode.Absolute:
                Settings.folderPathA = FolderField("Target folder", Settings.folderPathA);
                break;

            case Settings.PathMethode.SamePlace:
                break;

            case Settings.PathMethode.MirrorHierarchy:
                Settings.folderPathB = FolderField("Resemble Speechs root", Settings.folderPathB);
                Settings.folderPathA = FolderField("AudioClips root", Settings.folderPathA);
                break;
            }

            //Use subFolders
            Settings.useSubDirectory = EditorGUILayout.Toggle(useSubFolder, Settings.useSubDirectory);

            //Draw example image
            Texture image = Resources.instance.pathImages[(int)Settings.pathMethode * 2 + (Settings.useSubDirectory ? 1 : 0)];
            Rect    rect  = GUILayoutUtility.GetAspectRect(image.width / image.height);

            GUI.Label(rect, image);



            //Generation settings
            Utils.DrawSeparator();
            GUILayout.Space(20);
            GUILayout.Label("Generation", Styles.header);
            Settings.forceGeneration = !EditorGUILayout.Toggle(
                new GUIContent("Bypass if unchanged", "Bypass the generation if the clip is similar to the api one and just download the existing clip."),
                !Settings.forceGeneration);
            GUILayout.Space(10);
        }
Esempio n. 4
0
        private void DrawProjectSettingsGUI()
        {
            //Check changes
            EditorGUI.BeginChangeCheck();

            //Draw connection stuff
            EditorGUI.indentLevel++;
            DrawConnectGUI();
            EditorGUI.indentLevel--;
            Utils.DrawSeparator();
            GUILayout.Space(10);

            if (!Settings.connectionError && Settings.connected)
            {
                if (!Settings.haveProject)
                {
                    Rect rect = EditorGUILayout.BeginVertical(GUI.skin.box);
                    EditorGUI.DrawRect(rect.Shrink(1), new Color(1.0f, 1.0f, 1.0f, 0.2f));
                    rect = DrawProjectsSearchBar();
                    rect.Set(rect.x, rect.y + 20, rect.width, winRect.height - 200);
                    DrawProjectList(rect);
                    EditorGUILayout.EndVertical();

                    if (selected >= Settings.projects.Length)
                    {
                        selected = -1;
                    }
                    DrawProjectArea(selected == -1 ? null : Settings.projects[selected]);
                }
                else
                {
                    DrawProjectArea(Settings.project);
                }
            }

            //Apply changes to scriptable object
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(Settings.instance);
            }

            //Need constant repaint
            Repaint();
        }
Esempio n. 5
0
        public void DrawOneShotGUI()
        {
            //Check connection
            if (!Settings.haveProject)
            {
                Utils.ConnectionRequireMessage();
            }
            EditorGUI.BeginDisabledGroup(!Settings.haveProject);

            //Update progress bar if exist
            if (drawProgressBar)
            {
                EditorUtility.DisplayProgressBar("Resemble", "Download clip...", preview.download.progress);
                if (preview.download.isDone)
                {
                    drawProgressBar = false;
                    EditorUtility.ClearProgressBar();
                }
            }

            //Init components
            if (Resources.instance.oneShotText == null)
            {
                Resources.instance.oneShotText = new Text();
            }
            if (drawer == null)
            {
                drawer = new Text_Editor(Resources.instance.oneShotText, SetDirty, Repaint);
            }

            //Tags
            drawer.DrawTagsBtnsLayout(!Settings.haveProject);

            //Draw text area
            Rect rect = GUILayoutUtility.GetRect(Screen.width, 300).Shrink(10);

            drawer.DrawTextArea(rect, Settings.haveProject);

            //Draw char count progress bar
            rect.Set(rect.x, rect.y + rect.height, rect.width, 16);
            drawer.DrawCharCountBar(rect);
            GUILayout.Space(20);


            //Bot commands
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);

            //Voice field
            DrawVoiceField();

            //Generate button
            EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(voiceUUID) || string.IsNullOrEmpty(text.userString));
            if (GUILayout.Button("Generate audio", GUILayout.ExpandWidth(false)))
            {
                Generate();
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.Space(7);
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();


            //Footer
            GUILayout.FlexibleSpace();
            Utils.DrawSeparator();
            GUILayout.Label("The audio files generated here will not be saved in the Resemble project.", Styles.settingsBody);
        }
Esempio n. 6
0
            public void Draw(float width)
            {
                switch (type)
                {
                case Type.Text:
                    GUILayout.Label(label, Styles.settingsBody, GUILayout.Width(width));
                    break;

                case Type.Link:
                    if (index == -1)
                    {
                        if (GUILayout.Button(label, Styles.settingsLink, GUILayout.ExpandWidth(false)))
                        {
                            page.Open();
                        }
                        EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
                    }
                    else
                    {
                        if (GUILayout.Button(label, indent ? Styles.settingsLink : Styles.settingsIndex, GUILayout.ExpandWidth(false)))
                        {
                            scroll[2].y = titleHeights[index];
                        }
                        EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
                    }
                    break;

                case Type.Header:
                    GUILayout.Label(label, Styles.header, GUILayout.Width(width));
                    if (Event.current.type == EventType.Repaint)
                    {
                        titleHeights[titleID] = GUILayoutUtility.GetLastRect().y;
                    }
                    titleID++;
                    break;

                case Type.Title:
                    GUILayout.Label(label, Styles.header, GUILayout.Width(width));
                    break;

                case Type.Image:
                    GUILayout.Label(Resources.instance.docImages[index], Styles.settingsBody, GUILayout.Width(width));
                    break;

                case Type.Separator:
                    Utils.DrawSeparator();
                    break;

                case Type.Space:
                    GUILayout.Space(size);
                    break;

                case Type.Quote:
                    GUILayout.Label(label, Styles.settingsQuote, GUILayout.Width(width));
                    break;

                case Type.Code:
                    Color c = GUI.color;
                    GUI.color = new Color(0.25f, 0.25f, 0.25f, 1.0f);
                    GUILayout.BeginVertical(Styles.codeBox);
                    EditorGUILayout.SelectableLabel(label, Styles.settingsCode, GUILayout.Height(size), GUILayout.Width(width));
                    GUILayout.EndVertical();
                    GUI.color = c;
                    break;
                }
            }
Esempio n. 7
0
        public override void OnGUI(string searchContext)
        {
            //Init styles
            Styles.Load();

            //Set a min size on pref window
            if (prefWindow == null)
            {
                Assembly    assem = typeof(EditorWindow).Assembly;
                System.Type t     = assem.GetType("UnityEditor.PreferenceSettingsWindow");
                prefWindow         = EditorWindow.GetWindow(t, false, "Preferences", false);
                prefWindow.minSize = new Vector2(550, 500);
            }

            //Draw (project | options | help) toolbar
            DrawToolbar();

            //Open a scrollable layout area
            Utils.DrawSeparator();
            winRect = visualElement.contentRect.Offset(9, 30, -20, -80);
            GUI.BeginClip(winRect);
            GUILayout.BeginArea(new Rect(0, 5, winRect.width, winRect.height - 10));
            scroll[pageID] = GUILayout.BeginScrollView(scroll[pageID], GUIStyle.none);
            GUILayout.Space(5);

            //Draw page content
            switch (pageID)
            {
            default:
                DrawProjectSettingsGUI();
                break;

            case 1:
                DrawOptionsSettingsGUI();
                break;

            case 2:
                DrawHelpSettingsGUI();
                break;
            }

            //Close the scrollable layout area
            GUILayout.EndScrollView();
            GUILayout.EndArea();
            GUI.EndClip();
            GUILayout.Space(winRect.height - 20);
            Utils.DrawSeparator();

            //Draw page footer
            switch (pageID)
            {
            default:
                DrawProjectFooterGUI();
                break;

            case 1:
                DrawOptionsFooterGUI();
                break;

            case 2:
                DrawHelpFooterGUI();
                break;
            }
        }
        private void DrawOptionsSettingsGUI()
        {
            //Update settings
            GUILayout.Label("Update", Styles.header);
            bool drawRefreshButton = true;

            switch (Updates.status)
            {
            case Updates.Status.unknown:
                Updates.CheckStatus();
                Utils.DrawPendingLabel("Checking...");
                drawRefreshButton = false;
                break;

            case Updates.Status.checking:
                Utils.DrawPendingLabel("Checking...");
                drawRefreshButton = false;
                break;

            case Updates.Status.error:
                Utils.BoxWithLink("Unable to check for updates. Check your internet connection or update manually.",
                                  "Github page", WebPage.PluginGithub, MessageType.Error);
                break;

            case Updates.Status.updated:
                GUILayout.Label("Your plugin is up to date.");
                break;

            case Updates.Status.outdated:
                GUILayout.Label("Your plugin is out of date.");
                if (GUILayout.Button("Update"))
                {
                    Updates.Update();
                }
                EditorGUILayout.HelpBox("An outdated plugin may not work. It is strongly recommended to keep the plugin up to date.", MessageType.Warning);
                break;

            default:
                break;
            }
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (drawRefreshButton && GUILayout.Button("Refresh"))
            {
                Updates.CheckStatus();
            }
            if (Updates.status == Updates.Status.updated && GUILayout.Button("Reimport"))
            {
                Updates.Update();
            }
            GUILayout.EndHorizontal();


            //Path settings
            Utils.DrawSeparator();
            GUILayout.Space(20);
            GUILayout.Label(new GUIContent("Paths", "Describe where AudioClips from CharacterSets should be generated."), Styles.header);

            //Path methode
            Settings.pathMethode = (Settings.PathMethode)EditorGUILayout.EnumPopup(
                pathMethode, Settings.pathMethode);

            //Target folders fields
            switch (Settings.pathMethode)
            {
            case Settings.PathMethode.Absolute:
                Settings.folderPathA = FolderField("Target folder", Settings.folderPathA);
                break;

            case Settings.PathMethode.SamePlace:
                break;

            case Settings.PathMethode.MirrorHierarchy:
                Settings.folderPathB = FolderField("Resemble Speechs root", Settings.folderPathB);
                Settings.folderPathA = FolderField("AudioClips root", Settings.folderPathA);
                break;
            }

            //Use subFolders
            Settings.useSubDirectory = EditorGUILayout.Toggle(useSubFolder, Settings.useSubDirectory);

            //Draw example image
            Texture image = Resources.instance.pathImages[(int)Settings.pathMethode * 2 + (Settings.useSubDirectory ? 1 : 0)];
            Rect    rect  = GUILayoutUtility.GetAspectRect(image.width / image.height);

            GUI.Label(rect, image);



            //Generation settings
            Utils.DrawSeparator();
            GUILayout.Space(20);
            GUILayout.Label("Generation", Styles.header);
            Settings.forceGeneration = !EditorGUILayout.Toggle(
                new GUIContent("Bypass if unchanged", "Bypass the generation if the clip is similar to the api one and just download the existing clip."),
                !Settings.forceGeneration);
            GUILayout.Space(10);
        }