189 lines
6.9 KiB
C#
189 lines
6.9 KiB
C#
// #if UNITY_EDITOR
|
|
// namespace MusicCubeEditor
|
|
// {
|
|
// using CriWare;
|
|
// //using CriWare.Assets;
|
|
// using PhxhSDK;
|
|
// using System.Collections.Generic;
|
|
// using UnityEditor;
|
|
// using UnityEngine;
|
|
// using Constants = Framework.Constants;
|
|
// public class MusicCubeWindow : EditorWindow
|
|
// {
|
|
// List<cfg.AudioCfg.DataAudio> cfgList;
|
|
// private GameObject musicEditorObj;
|
|
// CriAtomSourceForAsset criAtomSource;
|
|
// public static void ShowWindow()
|
|
// {
|
|
// var window = GetWindow<MusicCubeWindow>();
|
|
// window.titleContent = new GUIContent("MusicCube配置工具");
|
|
// window.maximized = false;
|
|
// window.minSize = new Vector2(300, 300);
|
|
//
|
|
// int width = 600;
|
|
// int height = 400;
|
|
// var x = (Screen.currentResolution.width - width) / 2;
|
|
// var y = (Screen.currentResolution.height - height) / 2;
|
|
// Rect centerRect = new Rect(x, y, width, height);
|
|
// window.position = centerRect;
|
|
// window.Init();
|
|
// window.Show();
|
|
// window.Focus();
|
|
// MusicCubeEditorToolManager.Instance.OpenTestScene();
|
|
// EditorApplication.EnterPlaymode();
|
|
//
|
|
// }
|
|
//
|
|
// int nowFrameCount = 1;
|
|
// string[] musicNames;
|
|
// int selectedIndex = 0;
|
|
// int _nowIndex = 0;
|
|
// int selectdFrameCount;
|
|
//
|
|
// #region json序列化用
|
|
// MusicCubeEditorToolManager .OneMusicData all = new MusicCubeEditorToolManager.OneMusicData();
|
|
// MusicCubeEditorToolManager.OneFrameData nowFramedata = new MusicCubeEditorToolManager.OneFrameData();
|
|
//
|
|
// private CriAtomExOutputAnalyzer analyzer;
|
|
// string nowMusicName;
|
|
//
|
|
//
|
|
//
|
|
// #endregion
|
|
//
|
|
// void Init()
|
|
// {
|
|
// cfgList = Framework.EditorTableManager.instance.tables.Audios.DataList;
|
|
//
|
|
// List<string> itemNames = new List<string>();
|
|
// for (int i = 0; i < cfgList.Count; i++)
|
|
// {
|
|
// itemNames.Add("请选择Audio");
|
|
// itemNames.Add(cfgList[i].Key);
|
|
// }
|
|
//
|
|
// musicNames = itemNames.ToArray();
|
|
// MusicCubeEditorToolManager.Instance.nowPlayMusicName= musicNames[0];
|
|
// all= MusicCubeEditorToolManager.Instance.LoadConfig(musicNames[0]);
|
|
// }
|
|
//
|
|
// private void OnGUI()
|
|
// {
|
|
// #region EditorGUILayout.Popup 下拉
|
|
// _nowIndex = EditorGUILayout.Popup("music name", selectedIndex, musicNames);
|
|
// if (_nowIndex != selectedIndex)
|
|
// {
|
|
// if(_nowIndex!=0)
|
|
// {
|
|
// selectedIndex = _nowIndex;
|
|
// //SetAudioCfg();
|
|
// MusicCubeEditorToolManager.Instance.nowPlayMusicName = (musicNames[selectedIndex]);
|
|
// all = MusicCubeEditorToolManager.Instance.LoadConfig(musicNames[selectedIndex]);
|
|
//
|
|
// }
|
|
//
|
|
// }
|
|
// #endregion
|
|
// nowFrameCount = EditorGUILayout.IntSlider("第几帧:", nowFrameCount, 0, all.frameDatas.Count);
|
|
//
|
|
// if (nowFrameCount != selectdFrameCount)
|
|
// {
|
|
// selectdFrameCount = nowFrameCount;
|
|
// }
|
|
// GUILayout.TextArea("请填1到5的整数");
|
|
// GUILayout.BeginHorizontal();
|
|
//
|
|
// //for (int j = 0; j < 16; j++)
|
|
// //{
|
|
// // string n = GUILayout.TextField(all.frameDatas[nowFrameCount].ColData[j].ToString());
|
|
// // if (nowFramedata.ColData.Count < 16)
|
|
// // {
|
|
// // nowFramedata.ColData.Add(Convert.ToInt32(n));
|
|
// // }
|
|
// // else
|
|
// // {
|
|
// // nowFramedata.ColData[j] = Convert.ToInt32(n);
|
|
// // }
|
|
// //}
|
|
//
|
|
//
|
|
// GUILayout.EndHorizontal();
|
|
//
|
|
// GUILayout.BeginHorizontal();
|
|
//
|
|
// if (GUILayout.Button("保存修改"))
|
|
// {
|
|
// all.frameDatas[nowFrameCount]= nowFramedata;
|
|
// MusicCubeEditorToolManager.Instance.SaveConfig(all);
|
|
// }
|
|
// if (GUILayout.Button("预览"))
|
|
// {
|
|
// /*MusicCubeRun musicCubeRun = GameObject.Find("MusicCube").GetComponent<MusicCubeRun>();
|
|
// musicCubeRun.StartPlay(MusicCubeEditorToolManager.Instance.ConvertOneMusicDataToListArray(all));*/
|
|
// }
|
|
// if (GUILayout.Button("录制"))
|
|
// {
|
|
// SetOnPlay();
|
|
// }
|
|
// GUILayout.EndHorizontal();
|
|
//
|
|
// }
|
|
//
|
|
// int _cueIDs = 0;
|
|
// public int CueIDGen()
|
|
// {
|
|
// return ++_cueIDs;
|
|
// }
|
|
// private void SetAudioCfg()
|
|
// {
|
|
// string acbName = GetAudioName(musicNames[selectedIndex]);
|
|
// CriAtomAcbAsset acbAsset = AssetDatabase.LoadAssetAtPath<CriAtomAcbAsset>(acbName);
|
|
// //acbAsset.OnLoaded += Loaded;
|
|
//
|
|
// acbAsset.LoadImmediate();
|
|
// Loaded(acbAsset);
|
|
// }
|
|
// private void SetOnPlay()
|
|
// {
|
|
// AnalyerGenData ana = GameObject.Find("Analyzer").GetComponent<AnalyerGenData>();
|
|
// //ana.SetOnPlay(MusicCubeEditorToolManager.Instance.ChangeDataToJson, 6, nowMusicName);
|
|
// ana.SetOnPlay(MusicCubeEditorToolManager.Instance.ChangeDataToJson, 6, nowMusicName);
|
|
// EditorUtility.DisplayDialog("提示", "录制成功", "确定");
|
|
//
|
|
// }
|
|
//
|
|
// private void Loaded(CriAtomAcbAsset asset)
|
|
// {
|
|
// criAtomSource = GameObject.Find("CriAtomSource").GetComponent<CriAtomSourceForAsset>();
|
|
// CriAtomCueReference cueReference = new CriAtomCueReference(asset, 0);//CueIDGen());
|
|
// criAtomSource.Cue = cueReference;
|
|
// criAtomSource.loop = false;
|
|
// criAtomSource.volume = 1f;
|
|
// criAtomSource.use3dPositioning = false;
|
|
// EditorUtility.DisplayDialog("提示", "加载完毕", "确定");
|
|
//
|
|
// }
|
|
//
|
|
// private string GetAudioName(string oriname)
|
|
// {
|
|
// var audioData = Framework.EditorTableManager.instance.tables.Audios.GetByKey(oriname);
|
|
//
|
|
// var audioName = Constants.AUDIO_MUSIC_PATH + audioData.Path;
|
|
// string acfName = audioName + ".acf";
|
|
// LoadAcf(acfName);
|
|
//
|
|
// string acbName = audioName + ".acb";
|
|
// return acbName;
|
|
//
|
|
// }
|
|
// private async void LoadAcf(string acfName)
|
|
// {
|
|
// CriAtomAcfAsset acfAsset = await AssetManager.Instance.LoadAssetAsync<CriAtomAcfAsset>(acfName);
|
|
// acfAsset.Register();
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
//
|
|
// }
|
|
// #endif |