Beispiel #1
0
        /// <summary>
        /// Presetが存在しない時のロード画面のヘッダー
        /// </summary>
        void LoadPresetHeader()
        {
            EditorGUILayout.LabelField("VoicePresetをロード", VoiceerEditorUtility.Bold);
            EditorGUI.indentLevel++;
            {
                _loadedPreset =
                    (VoicePreset)EditorGUILayout.ObjectField("既存のPresetをロード", _loadedPreset, typeof(VoicePreset),
                                                             false);
            }
            EditorGUI.indentLevel--;
            VoiceerEditorUtility.Hr(position.width);
            GUILayout.Space(10);
            EditorGUILayout.LabelField("または");
            GUILayout.Space(10);
            VoiceerEditorUtility.Hr(position.width);
            EditorGUILayout.LabelField("VoicePresetの新規作成", VoiceerEditorUtility.Bold);

            EditorGUI.indentLevel++;
            {
                _outputDirectory = EditorGUILayout.TextField("出力フォルダ:", _outputDirectory);
                _presetName      = EditorGUILayout.TextField("ファイル名:", _presetName);

                EditorGUILayout.LabelField("出力先:" + Path.Combine(_outputDirectory, _presetName + _outputSuffix),
                                           VoiceerEditorUtility.Bold);

                if (GUILayout.Button("新規作成"))
                {
                    var exportedPath = CreateNewPreset();
                    _loadedPreset = AssetDatabase.LoadAssetAtPath(exportedPath, typeof(VoicePreset)) as VoicePreset;
                }
            }
            EditorGUI.indentLevel--;
            VoiceerEditorUtility.Hr(position.width);
        }
Beispiel #2
0
        public void CopyFrom(VoicePreset p)
        {
            this.voiceSetList = new List <Set>();

            foreach (Hook trigger in Enum.GetValues(typeof(Hook)))
            {
                if (GetVoiceSet(trigger) == null)
                {
                    voiceSetList.Add(new Set(trigger, new Sound()));
                }

                if (p.GetVoiceSet(trigger) != null)
                {
                    var sound = new Sound();
                    foreach (var clip in p.GetVoiceSet(trigger).voiceClips)
                    {
                        sound.voiceClips.Add(clip);
                    }
                    voiceSetList.Add(new Set(trigger, sound));
                }
            }


            this.metaData      = new Meta();
            this.metaData.memo = p.metaData.memo;
            this.metaData.url  = p.metaData.url;
        }
Beispiel #3
0
 /// <summary>
 /// Presetが存在する時の編集画面のヘッダー
 /// </summary>
 private void EditPresetHeader()
 {
     EditorGUILayout.LabelField("各+ボタンを押して、任意のAudioClipを追加してください。", VoiceerEditorUtility.Bold);
     EditorGUILayout.LabelField("(変更内容はオートセーブされます。)", VoiceerEditorUtility.Red);
     VoiceerEditorUtility.Hr(this.position.width);
     _loadedPreset =
         (VoicePreset)EditorGUILayout.ObjectField("現在のPreset", _loadedPreset, typeof(VoicePreset), false);
     GUILayout.Space(10);
 }
        public static void ExportPackage(VoicePreset preset)
        {
            var assetList = new List <string>();

            assetList.Add(AssetDatabase.GetAssetPath(preset));

            foreach (var voiceClip in preset.voiceSetList.SelectMany(set => set.sound.voiceClips))
            {
                if (voiceClip != null)
                {
                    assetList.Add(AssetDatabase.GetAssetPath(voiceClip));
                }
            }

            AssetDatabase.ExportPackage(
                assetList.ToArray()
                , $"{preset.name}.unitypackage"
                , ExportPackageOptions.Interactive);
        }
Beispiel #5
0
        private void OnGUI()
        {
            VoiceerEditorUtility.UiTitleBox(TitleString, VoiceerEditorUtility.BackGroundImage);

            if (_loadedPreset == null)
            {
                LoadPresetHeader();
                return;
            }

            EditPresetHeader();

            _loadedPreset.hideFlags     = HideFlags.NotEditable;
            _loadedPreset.metaData.url  = EditorGUILayout.TextField("URL:", _loadedPreset.metaData.url);
            _loadedPreset.metaData.memo = EditorGUILayout.TextField("その他:", _loadedPreset.metaData.memo);

            GUILayout.Space(20);

            _scrollPos = GUILayout.BeginScrollView(_scrollPos);
            {
                EditorGUI.BeginChangeCheck();
                {
                    foreach (Hook trigger in Enum.GetValues(typeof(Hook)))
                    {
                        if (_loadedPreset.GetVoiceSet(trigger) == null)
                        {
                            _loadedPreset.voiceSetList.Add(new VoicePreset.Set(trigger, new Sound()));
                        }

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField(VoiceerEditorUtility.GetDescriptionLabel(trigger),
                                                   VoiceerEditorUtility.Bold);

                        var clips = _loadedPreset.GetVoiceSet(trigger).voiceClips;

                        if (_loadedPreset.GetVoiceSet(trigger).voiceClips.Count != 0)
                        {
                            if (GUILayout.Button("-", GUILayout.Width(30)))
                            {
                                clips.RemoveRange(clips.Count - 1, 1);
                            }
                        }

                        if (GUILayout.Button("+", GUILayout.Width(30)))
                        {
                            clips.Add(null);
                        }

                        EditorGUILayout.EndHorizontal();

                        EditorGUI.indentLevel++;
                        for (int i = 0; i < _loadedPreset.GetVoiceSet(trigger).voiceClips.Count; i++)
                        {
                            _loadedPreset.GetVoiceSet(trigger).voiceClips[i] =
                                (AudioClip)EditorGUILayout.ObjectField(
                                    _loadedPreset.GetVoiceSet(trigger).voiceClips[i],
                                    typeof(AudioClip), false);
                        }

                        EditorGUI.indentLevel--;
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(_loadedPreset);
                    AssetDatabase.SaveAssets();
                    // エディタを最新の状態にする
                    AssetDatabase.Refresh();
                }
            }
            GUILayout.EndScrollView();

            GUILayout.Space(10);
            VoiceerEditorUtility.Hr(position.width);
            if (GUILayout.Button("Preset選択モードに戻る"))
            {
                _loadedPreset = null;
            }
            GUILayout.Space(10);
            if (GUILayout.Button("パッケージを出力する"))
            {
                VoiceerEditorUtility.ExportPackage(_loadedPreset);
            }
        }