Beispiel #1
0
 protected virtual void LayoutContent()
 {
     if (!string.IsNullOrEmpty(ContentSubheaderLabel))
     {
         WitEditorUI.LayoutSubheaderLabel(ContentSubheaderLabel);
         GUILayout.Space(WitStyles.HeaderPaddingBottom * 2f);
     }
     GUILayout.BeginHorizontal();
     GUILayout.Space(WitStyles.WizardFieldPadding);
     GUILayout.BeginVertical();
     LayoutFields();
     GUILayout.EndVertical();
     GUILayout.Space(WitStyles.WizardFieldPadding);
     GUILayout.EndHorizontal();
 }
        // Layout Preload Data
        protected virtual void LayoutPreloadData()
        {
            // For updates
            bool updated = false;

            // Layout preload items
            GUILayout.Space(WitStyles.WindowPaddingBottom);
            GUILayout.BeginHorizontal();
            WitEditorUI.LayoutSubheaderLabel("TTS Preload Data");
            if (WitEditorUI.LayoutTextButton("Add Voice"))
            {
                AddVoice();
                updated = true;
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            // Indent
            EditorGUI.indentLevel++;

            // Generate
            if (Settings.data == null)
            {
                Settings.data = new TTSPreloadData();
            }
            if (Settings.data.voices == null)
            {
                Settings.data.voices = new TTSPreloadVoiceData[] { new TTSPreloadVoiceData() };
            }

            // Begin scroll
            for (int v = 0; v < Settings.data.voices.Length; v++)
            {
                if (!LayoutVoiceData(Settings.data, v, ref updated))
                {
                    break;
                }
            }

            // Set dirty
            if (updated)
            {
                EditorUtility.SetDirty(Settings);
            }

            // Indent
            EditorGUI.indentLevel--;
        }
        // Layout Preload Data
        protected virtual void LayoutPreloadActions()
        {
            // Layout preload actions
            EditorGUILayout.Space();
            WitEditorUI.LayoutSubheaderLabel("TTS Preload Actions");

            // Indent
            EditorGUI.indentLevel++;
            EditorGUILayout.Space();

            // Hide when playing
            if (Application.isPlaying)
            {
                EditorUtility.ClearProgressBar();
                WitEditorUI.LayoutErrorLabel("TTS preload actions cannot be performed at runtime.");
                EditorGUI.indentLevel--;
                return;
            }

            // Get TTS Service if needed
            TtsService = EditorGUILayout.ObjectField("TTS Service", TtsService, typeof(TTSService), true) as TTSService;
            if (TtsService == null)
            {
                EditorUtility.ClearProgressBar();
                TtsService = GameObject.FindObjectOfType <TTSService>();
                WitEditorUI.LayoutErrorLabel("You must add a TTS Service to the loaded scene in order perform TTS actions.");
                EditorGUI.indentLevel--;
                return;
            }
            if (TtsService != null && _ttsVoiceIDs == null)
            {
                _ttsVoiceIDs = GetVoiceIDs(TtsService);
            }

            // Begin buttons
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();

            // Import JSON
            GUILayout.Space(ACTION_BTN_INDENT * EditorGUI.indentLevel);
            if (WitEditorUI.LayoutTextButton("Refresh Data"))
            {
                RefreshData();
            }
            GUILayout.Space(ACTION_BTN_INDENT);
            if (WitEditorUI.LayoutTextButton("Import JSON"))
            {
                EditorUtility.ClearProgressBar();
                if (TTSPreloadUtility.ImportData(Settings))
                {
                    RefreshData();
                }
            }
            // Clear disk cache
            GUI.enabled = TtsService != null;
            EditorGUILayout.Space();
            Color col = GUI.color;

            GUI.color = Color.red;
            if (WitEditorUI.LayoutTextButton("Delete Cache"))
            {
                EditorUtility.ClearProgressBar();
                TTSPreloadUtility.DeleteData(TtsService);
                RefreshData();
            }
            // Preload disk cache
            GUILayout.Space(ACTION_BTN_INDENT);
            GUI.color = Color.green;
            if (WitEditorUI.LayoutTextButton("Preload Cache"))
            {
                DownloadClips();
            }
            GUI.color   = col;
            GUI.enabled = true;

            // End buttons
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            // Indent
            EditorGUI.indentLevel--;
        }