public override void OnWizardGUI()
        {
            EditorGUI.BeginDisabledGroup(locked);
            switch (currentStep)
            {
            case 1:
                EditorGUILayout.HelpBox("This wizard will guide you through setting up AutoSync for your current project.\nCheck the auto-detected settings below (based on your system) and press 'Continue' to apply them.", MessageType.Info);
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Operating System", detectedOS);
                EditorGUILayout.HelpBox("SoX Sound Exchange is a third-party library that AutoSync can use to convert audio files to the correct format to be processed, making it compatible with a wider range of files.", MessageType.Info);
                soXPath = LipSyncEditorExtensions.DrawPathField("SoX Sound Exchange Path", soXPath, "ls_debug", "Find SoX Sound Exchange");
                EditorGUILayout.Space();
                LipSyncEditorExtensions.BeginPaddedHorizontal(20);
                if (GUILayout.Button("Auto-Detect Path", GUILayout.MaxWidth(250), GUILayout.Height(20)))
                {
                    DetectPaths();
                }
                LipSyncEditorExtensions.EndPaddedHorizontal(20);
                EditorGUILayout.Space();
                if (osLin)
                {
                    EditorGUILayout.HelpBox("The Linux editor is not officially supported at this time, some AutoSync features may still work, but the PocketSphinx module and SoX audio conversion are not supported.", MessageType.Error);
                    EditorGUILayout.Space();
                }
                else if (osMac)
                {
                    EditorGUILayout.HelpBox("Note that the included PocketSphinx module is not supported on most versions of macOS. Follow the instructions on the next screen for more info.", MessageType.Warning);
                    EditorGUILayout.Space();
                }

                break;

            case 2:
                GUILayout.Label("Installed Modules", EditorStyles.boldLabel);
                GUILayout.BeginHorizontal();
                GUILayout.Space(10);
                GUILayout.BeginVertical();
                if (moduleInfos != null)
                {
                    for (int i = 0; i < moduleInfos.Count; i++)
                    {
                        GUILayout.Label(moduleInfos[i].displayName);
                    }
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();
                if (mfaFound)
                {
                    EditorGUILayout.HelpBox("It looks like all recommended modules are installed. Feel free to download others from the Extension Window.", MessageType.Info);
                }
                else
                {
                    EditorGUILayout.HelpBox("In order to keep the initial download size down, only the legacy PocketSphinx module is included. For best results (and compatibility with macOS) we recommend downloading the Montreal Forced Aligner module, which makes use of both the audio clip and a text transcript to create much more accurate lip-sync animation.", MessageType.Info);
                    if (GUILayout.Button("Start Downloading Montreal Forced Aligner", GUILayout.Height(25)))
                    {
                        locked      = true;
                        canContinue = false;

                        if (osMac)
                        {
                            RDExtensionWindow.RequestInstall("AutoSync Montreal Forced Aligner Module (Mac)");
                        }
                        else if (!osLin)
                        {
                            RDExtensionWindow.RequestInstall("AutoSync Montreal Forced Aligner Module (Win)");
                        }
                    }
                }

                break;

            case 3:
                EditorGUILayout.HelpBox("This section contains setup for individual modules. You may want to run this wizard again later if you download additional modules that require setup, or you may configure them manually from the AutoSync settings page in the Clip Editor.", MessageType.Info);
                EditorGUILayout.Space();

                for (int i = 0; i < moduleInfos.Count; i++)
                {
                    if (moduleInfos[i].moduleSettingsType != null)
                    {
                        GUILayout.Label(moduleInfos[i].displayName + " Setup", EditorStyles.boldLabel);
                        settingsObjects[i].DrawSetupWizardSection();
                        EditorGUILayout.Space();
                    }
                }
                break;
            }
            EditorGUI.EndDisabledGroup();

            if (locked)
            {
                GUILayout.Space(10);
                if (GUILayout.Button("Continue Wizard Anyway", GUILayout.Height(30)))
                {
                    locked      = false;
                    canContinue = true;
                    RemoveNotification();
                }

                ShowNotification(new GUIContent("Please allow the download to finish + install before returning to this wizard."));
            }
        }
Ejemplo n.º 2
0
    void OnGUI()
    {
        EditorStyles.label.wordWrap = true;

        GUILayout.Space(10);
        tab = GUILayout.Toolbar(tab, new string[] { "AutoSync Settings", "Batch Process" });
        GUILayout.Space(10);

        bool ready = true;

        if (tab == 0)
        {
            ready = currentModules.Count > 0;

            GUILayout.Space(5);
            GUILayout.Box("Presets", EditorStyles.boldLabel);
            GUILayout.Space(5);
            presetScroll = GUILayout.BeginScrollView(presetScroll, GUILayout.MaxHeight(80));
            if (presets.Length == 0)
            {
                GUILayout.Space(10);
                GUILayout.Box("No Presets Found", EditorStyles.centeredGreyMiniLabel);
            }
            else
            {
                EditorGUILayout.BeginVertical();
                for (int i = -1; i < presets.Length; i++)
                {
                    var lineRect = EditorGUILayout.BeginHorizontal();
                    if (i == presetHighlight)
                    {
                        GUI.Box(lineRect, "", (GUIStyle)"SelectionRect");
                    }

                    if (i >= 0)
                    {
                        if (GUILayout.Button(presets[i].displayName, EditorStyles.label))
                        {
                            LoadPreset(i);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("None", EditorStyles.label))
                        {
                            LoadPreset(-1);
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndScrollView();
            GUILayout.Space(5);
            var infoRect = EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            GUI.Box(infoRect, "", EditorStyles.helpBox);
            GUILayout.Space(5);
            if (presetHighlight == -1)
            {
                GUILayout.Box(new GUIContent("Select a preset for more information.", infoIcon), EditorStyles.label);
            }
            else
            {
                GUILayout.Box(presets[presetHighlight].displayName, EditorStyles.boldLabel);
                EditorGUILayout.LabelField(presets[presetHighlight].description, EditorStyles.label);
                GUILayout.Space(5);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            GUILayout.Space(5);
            EditorGUILayout.EndVertical();
            GUILayout.Space(5);
            Rect toolbarRect = EditorGUILayout.BeginHorizontal();
            toolbarRect.x = 0;
            GUI.Box(toolbarRect, "", EditorStyles.toolbar);
            GUILayout.Box("Current Modules", EditorStyles.miniLabel);
            GUILayout.FlexibleSpace();
            Rect dropDownRect = EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Add", plusIcon, "Add a new module to the list"), EditorStyles.toolbarDropDown, GUILayout.Width(70)))
            {
                GenericMenu addMenu = new GenericMenu();
                for (int i = 0; i < autoSyncModuleTypes.Count; i++)
                {
                    bool isAdded = false;

                    for (int m = 0; m < currentModules.Count; m++)
                    {
                        if (currentModules[m].GetType() == autoSyncModuleTypes[i])
                        {
                            isAdded = true;
                            break;
                        }
                    }

                    if (isAdded)
                    {
                        addMenu.AddDisabledItem(new GUIContent(moduleInfos[autoSyncModuleTypes[i]].displayName));
                    }
                    else
                    {
                        int e = i;
                        addMenu.AddItem(new GUIContent(moduleInfos[autoSyncModuleTypes[i]].displayName), false, () => { AddModule(e); });
                    }
                }
                addMenu.AddSeparator("");
                addMenu.AddItem(new GUIContent("Get More Modules"), false, () => { RDExtensionWindow.ShowWindow("LipSync_Pro"); });
                addMenu.DropDown(dropDownRect);
            }
            if (GUILayout.Button(new GUIContent("New Preset", saveIcon, "Save the current setup as a new preset"), EditorStyles.toolbarButton, GUILayout.Width(90)))
            {
                var savePath = EditorUtility.SaveFilePanelInProject("Save AutoSync Preset", "New AutoSync Preset", "asset", "");
                if (!string.IsNullOrEmpty(savePath))
                {
                    AutoSyncPreset preset = null;

                    if (File.Exists(savePath))
                    {
                        preset = AssetDatabase.LoadAssetAtPath <AutoSyncPreset>(savePath);
                    }
                    else
                    {
                        preset = CreateInstance <AutoSyncPreset>();
                        preset.CreateFromModules(currentModules.ToArray());

                        preset.displayName = Path.GetFileNameWithoutExtension(savePath);
                        preset.description = "Using: ";
                        for (int i = 0; i < currentModules.Count; i++)
                        {
                            preset.description += currentModules[i].GetType().Name;
                            if (i < currentModules.Count - 1)
                            {
                                preset.description += ", ";
                            }
                        }
                    }

                    AssetDatabase.CreateAsset(preset, savePath);
                    AssetDatabase.Refresh();

                    presets         = AutoSyncUtility.GetPresets();
                    presetHighlight = -1;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginVertical();
            settingsScroll = GUILayout.BeginScrollView(settingsScroll, false, false);
            if (currentModules.Count == 0)
            {
                GUILayout.Space(10);
                GUILayout.Box("No Modules Added", EditorStyles.centeredGreyMiniLabel);
            }
            else
            {
                for (int i = 0; i < currentModules.Count; i++)
                {
                    var type = currentModules[i].GetType();
                    var info = moduleInfos[type];
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);
                    GUILayout.Box(new GUIContent(info.displayName, infoIcon, info.description), EditorStyles.label);
                    GUILayout.Space(10);
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical(GUILayout.Width(15));
                    GUILayout.Space(10);
                    if (GUILayout.Button(new GUIContent(minusIcon, "Remove Module")))
                    {
                        DestroyImmediate(serializedModules[i]);
                        DestroyImmediate(currentModules[i]);
                        serializedModules.RemoveAt(i);
                        currentModules.RemoveAt(i);
                        break;
                    }
                    GUILayout.Space(5);
                    EditorGUI.BeginDisabledGroup(i == 0);
                    if (GUILayout.Button(new GUIContent(upIcon, "Move Up")))
                    {
                        currentModules.Insert(i - 1, currentModules[i]);
                        currentModules.RemoveAt(i + 1);
                        serializedModules.Insert(i - 1, serializedModules[i]);
                        serializedModules.RemoveAt(i + 1);
                        break;
                    }
                    EditorGUI.EndDisabledGroup();
                    EditorGUI.BeginDisabledGroup(i + 2 > currentModules.Count);
                    if (GUILayout.Button(new GUIContent(downIcon, "Move Down")))
                    {
                        currentModules.Insert(i + 2, currentModules[i]);
                        currentModules.RemoveAt(i);
                        serializedModules.Insert(i + 2, serializedModules[i]);
                        serializedModules.RemoveAt(i);
                        break;
                    }
                    EditorGUI.EndDisabledGroup();
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                    var missing = GetMissingClipFeaturesInClipEditor(currentModules, i);
                    if (missing != ClipFeatures.None)
                    {
                        EditorGUILayout.HelpBox(string.Format("This module requires: {0}.\n These features must either be present in the clip already, or be provided by a module above this one.", missing), MessageType.Error);
                    }
                    serializedModules[i].OnInspectorGUI();
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                    GUILayout.Space(15);
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.Space(5);
            GUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(!ready);
            if (GUILayout.Button("Start Single Process", GUILayout.Height(25)))
            {
                if (autoSyncInstance == null)
                {
                    autoSyncInstance = new AutoSync();
                }

                autoSyncInstance.RunSequence(currentModules.ToArray(), FinishedProcessingSingle, (LipSyncData)setup.data);
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(20);
        }
        else
        {
            ready = clips.Count > 0 && currentModules.Count > 0;

            GUILayout.Space(5);
            GUILayout.Box("Select AudioClips", EditorStyles.boldLabel);
            GUILayout.Space(5);
            batchScroll = GUILayout.BeginScrollView(batchScroll);
            for (int a = 0; a < clips.Count; a++)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(5);
                clips[a] = (AudioClip)EditorGUILayout.ObjectField(clips[a], typeof(AudioClip), false);
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Remove", GUILayout.MaxWidth(200)))
                {
                    clips.RemoveAt(a);
                    break;
                }
                GUILayout.Space(5);
                GUILayout.EndHorizontal();
            }
            GUILayout.Space(5);
            GUILayout.EndScrollView();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add AudioClip"))
            {
                clips.Add(null);
            }
            if (GUILayout.Button("Add Selected"))
            {
                foreach (AudioClip c in Selection.GetFiltered(typeof(AudioClip), SelectionMode.Assets))
                {
                    if (!clips.Contains(c))
                    {
                        clips.Add(c);
                    }
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10);
            EditorGUILayout.HelpBox("Settings from the AutoSync Settings tab will be used. Make sure they are correct.", MessageType.Info);
            xmlMode         = EditorGUILayout.Toggle("Export as XML", xmlMode);
            loadTranscripts = EditorGUILayout.Toggle("Load Transcripts .txt", loadTranscripts);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(!ready);
            if (GUILayout.Button("Start Batch Process", GUILayout.Height(25)))
            {
                currentClip = 0;

                if (clips.Count > 0)
                {
                    if (autoSyncInstance == null)
                    {
                        autoSyncInstance = new AutoSync();
                    }

                    LipSyncData tempData = CreateInstance <LipSyncData>();
                    tempData.clip   = clips[currentClip];
                    tempData.length = tempData.clip.length;

                    if (loadTranscripts)
                    {
                        tempData.transcript = AutoSyncUtility.TryGetTranscript(tempData.clip);
                    }

                    autoSyncInstance.RunSequence(currentModules.ToArray(), FinishedProcessingMulti, tempData);
                }
                else
                {
                    ShowNotification(new GUIContent("No clips added for batch processing!"));
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Space(20);
        }
    }
Ejemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box(logo, GUIStyle.none);
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("Project Settings", EditorStyles.boldLabel);
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(20);
        EditorGUILayout.PropertyField(phonemeSet, new GUIContent("Phoneme Set"));
        GUILayout.Space(15);

        GUILayout.Box("Animation Emotions", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        Undo.RecordObject(myTarget, "Change Project Settings");
        EditorGUI.BeginDisabledGroup(true);
        for (int a = 0; a < myTarget.emotions.Length; a++)
        {
            Rect lineRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(25));
            if (a % 2 == 0)
            {
                GUI.Box(lineRect, "", (GUIStyle)"hostview");
            }
            GUILayout.Space(10);
            GUILayout.Box((a + 1).ToString(), EditorStyles.label);
            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            emotions.GetArrayElementAtIndex(a).stringValue = GUILayout.TextArea(emotions.GetArrayElementAtIndex(a).stringValue, EditorStyles.label, GUILayout.MinWidth(130));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                emotions.GetArrayElementAtIndex(a).stringValue = Validate(a, myTarget.emotions);
            }


            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Text);
            GUILayout.FlexibleSpace();
            emotionColors.GetArrayElementAtIndex(a).colorValue = EditorGUILayout.ColorField(emotionColors.GetArrayElementAtIndex(a).colorValue, GUILayout.MaxWidth(280));
            GUILayout.FlexibleSpace();
            GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f);
            if (GUILayout.Button("Delete", GUILayout.MaxWidth(70), GUILayout.Height(18)))
            {
                emotions.DeleteArrayElementAtIndex(a);
                emotionColors.DeleteArrayElementAtIndex(a);
                break;
            }
            GUI.backgroundColor = Color.white;
            GUILayout.Space(10);
            EditorGUILayout.EndHorizontal();
        }

        GUILayout.Space(10);
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Add Emotion", GUILayout.MaxWidth(300), GUILayout.Height(25)))
        {
            emotions.arraySize++;
            emotionColors.arraySize++;

            emotions.GetArrayElementAtIndex(emotions.arraySize - 1).stringValue          = "New Emotion";
            emotionColors.GetArrayElementAtIndex(emotionColors.arraySize - 1).colorValue = Color.white;

            serializedObject.ApplyModifiedProperties();
            emotions.GetArrayElementAtIndex(emotions.arraySize - 1).stringValue = Validate(emotions.arraySize - 1, myTarget.emotions);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.Space(20);

        GUILayout.Box("Animation Gestures", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        for (int a = 0; a < myTarget.gestures.Count; a++)
        {
            Rect lineRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(25));
            if (a % 2 == 0)
            {
                GUI.Box(lineRect, "", (GUIStyle)"hostview");
            }
            GUILayout.Box((a + 1).ToString(), EditorStyles.label);
            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            gestures.GetArrayElementAtIndex(a).stringValue = GUILayout.TextArea(gestures.GetArrayElementAtIndex(a).stringValue, EditorStyles.label, GUILayout.MinWidth(130));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                gestures.GetArrayElementAtIndex(a).stringValue = Validate(a, myTarget.gestures.ToArray());
            }

            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Text);
            GUILayout.FlexibleSpace();
            GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f);
            if (GUILayout.Button("Delete", GUILayout.MaxWidth(70), GUILayout.Height(18)))
            {
                gestures.DeleteArrayElementAtIndex(a);
                break;
            }
            GUI.backgroundColor = Color.white;
            GUILayout.Space(10);
            EditorGUILayout.EndHorizontal();
        }

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Add Gesture", GUILayout.MaxWidth(300), GUILayout.Height(25)))
        {
            gestures.arraySize++;
            gestures.GetArrayElementAtIndex(gestures.arraySize - 1).stringValue = "New Gesture";

            serializedObject.ApplyModifiedProperties();
            gestures.GetArrayElementAtIndex(gestures.arraySize - 1).stringValue = Validate(gestures.arraySize - 1, myTarget.gestures.ToArray());
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.Space(20);
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.HelpBox("Thank you for trying LipSync Lite! Upgrade to LipSync Pro to unlock additional features, such as AutoSync and Emotion markers!", MessageType.Info);

        if (GUILayout.Button("Get LipSync Pro"))
        {
            Application.OpenURL("http://u3d.as/cag");
        }
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Get LipSync Extensions"))
        {
            RDExtensionWindow.ShowWindow("LipSync_Lite");
        }
        if (GUILayout.Button("Forum Thread"))
        {
            Application.OpenURL("http://forum.unity3d.com/threads/released-lipsync-and-eye-controller-lipsyncing-and-facial-animation-tools.309324/");
        }
        if (GUILayout.Button("Website"))
        {
            Application.OpenURL("http://lipsync.rogodigital.com/");
        }
        EditorGUILayout.EndHorizontal();
        serializedObject.ApplyModifiedProperties();
    }