主界面音乐方块上传
parent
50e1e43947
commit
4b3bf4a10e
|
|
@ -0,0 +1,154 @@
|
|||
using CriWare;
|
||||
using CriWare.Assets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
public class AnalyerTest : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
|
||||
private CriAtomExOutputAnalyzer analyzer;
|
||||
float playtime;
|
||||
private List<float[]> list = new List<float[]>();
|
||||
CriAtomSourceForAsset atomAsset;
|
||||
public Action<List<float[]>> onPlay;
|
||||
bool islist = false;
|
||||
void Start()
|
||||
{
|
||||
analyzer = new CriAtomExOutputAnalyzer(NewConfig());
|
||||
atomAsset = GameObject.Find("CriAtomSource").GetComponent<CriAtomSourceForAsset>();
|
||||
atomAsset.AttachToAnalyzer(analyzer);
|
||||
//playtime = atomAsset.time / 1000;
|
||||
playtime = 5;
|
||||
DebugUtil.Log("onPlay是否为空" + (onPlay == null));
|
||||
}
|
||||
public void SetOnPlay(Action<List<float[]>> action)
|
||||
{
|
||||
onPlay = action;
|
||||
atomAsset.Play();
|
||||
islist = true;
|
||||
}
|
||||
|
||||
|
||||
CriWare.CriAtomExOutputAnalyzer.Config NewConfig()
|
||||
{
|
||||
CriWare.CriAtomExOutputAnalyzer.Config config = new CriAtomExOutputAnalyzer.Config();
|
||||
config.enableSpectrumAnalyzer = true;
|
||||
config.numSpectrumAnalyzerBands = 16;
|
||||
return config;
|
||||
}
|
||||
float[] levels = new float[16];
|
||||
float nowtime;
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (!islist)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (nowtime <= playtime)
|
||||
{
|
||||
analyzer.GetSpectrumLevels(ref levels);
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
if (levels[i] * 100 > 10)
|
||||
{
|
||||
levels[i] = (2 + levels[i] * 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
levels[i] = (2 - levels[i] * 100);
|
||||
|
||||
}
|
||||
}
|
||||
list.Add(levels);
|
||||
nowtime += Time.deltaTime;
|
||||
DebugUtil.Log(nowtime);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (islist)
|
||||
{
|
||||
_SaveConfig(new OneMusicData(list));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public class OneMusicData
|
||||
{
|
||||
public string name;
|
||||
public List<OneFrameData> frameDatas = new List<OneFrameData>();
|
||||
public OneMusicData()
|
||||
{
|
||||
name = "fff";
|
||||
|
||||
for (int i = 0; i < 60; i++)
|
||||
{
|
||||
frameDatas.Add(new OneFrameData());
|
||||
}
|
||||
}
|
||||
public OneMusicData(List<float[]> list)
|
||||
{
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
frameDatas.Add(new OneFrameData(list[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
|
||||
public class OneFrameData
|
||||
{
|
||||
public List<int> ColData = new List<int>();
|
||||
public OneFrameData()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
ColData.Add(0);
|
||||
}
|
||||
}
|
||||
public OneFrameData(float[] s)
|
||||
{
|
||||
for (int i = 0; i < s.Length; i++)
|
||||
{
|
||||
ColData.Add(Convert.ToInt16(s[i]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void _SaveConfig(OneMusicData saveData)
|
||||
{
|
||||
// 保存timeline
|
||||
//var director = _cmp.gameObject.GetComponent<PlayableDirector>();
|
||||
//var playAsset = director.playableAsset as TimelineAsset;
|
||||
// 保存json到本地
|
||||
{
|
||||
var json = JsonUtility.ToJson(saveData);
|
||||
var savePath = "Assets/Config/UISomeAbout/MainPanelMusicCube/";
|
||||
var saveName = saveData + ".json";
|
||||
var fullPath = savePath + "/" + saveName;
|
||||
var realPath = Application.dataPath + fullPath.Substring(6);
|
||||
if (File.Exists(realPath))
|
||||
{
|
||||
//if (VersionControlUtils.IsPathVersioned(fullPath))
|
||||
//{
|
||||
// Provider.Checkout(fullPath, CheckoutMode.Both).Wait();
|
||||
//}
|
||||
File.Delete(realPath);
|
||||
}
|
||||
File.WriteAllText(realPath, json);
|
||||
Debug.Log("json保存成功:" + fullPath);
|
||||
}
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
// 弹出对话框提示
|
||||
EditorUtility.DisplayDialog("提示", "保存成功", "确定");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
using CriWare;
|
||||
using CriWare.Assets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AnalyerGenData : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
|
||||
private CriAtomExOutputAnalyzer analyzer;
|
||||
float playtime;
|
||||
private List<float[]> list;
|
||||
CriAtomSourceForAsset atomAsset;
|
||||
public Action<List<float[]>> onPlay;
|
||||
bool islist = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
EditorAudioManager.Instance.Init();
|
||||
EditorAudioManager.Instance.Start();
|
||||
nowtime = 0;
|
||||
list = new List<float[]>();
|
||||
analyzer = new CriAtomExOutputAnalyzer(NewConfig());
|
||||
GenOnePeriodData();
|
||||
|
||||
}
|
||||
public async void SetOnPlay(Action<List<float[]>> action, int time, string musicName)
|
||||
{
|
||||
//ResetData();
|
||||
//AttachAnalyzer();
|
||||
playtime = time;
|
||||
onPlay = action;
|
||||
EditorAudioManager.Instance.RegisterAnalyzer(analyzer);
|
||||
await EditorAudioManager.Instance.PlayAudio("DemoProj_M1");
|
||||
atomAsset = GameObject.Find("Audio(Singleton)").GetComponent<CriAtomSourceForAsset>();
|
||||
|
||||
DebugUtil.Log("时间" + atomAsset.time);
|
||||
//atomAsset.Play("bgm_01");
|
||||
islist = true;
|
||||
}
|
||||
void GenOnePeriodData()
|
||||
{
|
||||
float[] temp3 = new float[16];
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
float y = amplitude * Mathf.Sin(i * (2 * (Mathf.PI / 16)));
|
||||
y = y + 2;
|
||||
|
||||
temp3[i] = y;
|
||||
}
|
||||
temp3[temp3.Length - 1] = 2;
|
||||
list.Add(temp3);
|
||||
float[] lastArray = temp3;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
float[] newArray =new float[16];
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
newArray[(j + 1) % 16] = lastArray[j];
|
||||
}
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
lastArray[k] = (newArray[k]);
|
||||
|
||||
}
|
||||
list.Add(newArray);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GetNewOnePeriodData()
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private bool SplitBandsOnLogScale(ref float[] iLinearLvs, ref float[] oLogLvs)
|
||||
{
|
||||
if (iLinearLvs == null || oLogLvs == null)
|
||||
return false;
|
||||
float lowBand, highBand, tmpVal;
|
||||
int lowBandIdx, highBandIdx, i, j;
|
||||
int iBandCnt = iLinearLvs.Length;
|
||||
int oBandCnt = oLogLvs.Length;
|
||||
for (i = 0; i < oBandCnt; ++i)
|
||||
{
|
||||
/* 指定の対数スケールバンドに対応する、リニア周波数軸上の範囲を求める */
|
||||
lowBand = Mathf.Pow((float)iBandCnt, (float)i / (float)oBandCnt);
|
||||
highBand = Mathf.Pow((float)iBandCnt, (float)(i + 1) / (float)oBandCnt);
|
||||
/* 両端を丸める */
|
||||
lowBandIdx = Mathf.FloorToInt(lowBand) - 1;
|
||||
highBandIdx = Mathf.FloorToInt(highBand) - 1;
|
||||
/* 範囲内のレベルの平均値を求める */
|
||||
tmpVal = 0;
|
||||
for (j = lowBandIdx; j <= highBandIdx; ++j)
|
||||
{
|
||||
tmpVal += iLinearLvs[j];
|
||||
}
|
||||
tmpVal = tmpVal / (float)(highBandIdx - lowBandIdx + 1);
|
||||
/* 対数スケールのレベル値を出力する */
|
||||
oLogLvs[i] = tmpVal;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ResetData()
|
||||
{
|
||||
list.Clear();
|
||||
nowtime = 0;
|
||||
}
|
||||
void AttachAnalyzer()
|
||||
{
|
||||
atomAsset.AttachToAnalyzer(analyzer);
|
||||
}
|
||||
CriWare.CriAtomExOutputAnalyzer.Config NewConfig()
|
||||
{
|
||||
CriWare.CriAtomExOutputAnalyzer.Config config = new CriAtomExOutputAnalyzer.Config();
|
||||
config.enableSpectrumAnalyzer = true;
|
||||
config.numSpectrumAnalyzerBands = 16;
|
||||
return config;
|
||||
}
|
||||
float[] levels = new float[16];
|
||||
float nowtime;
|
||||
// Update is called once per frame
|
||||
|
||||
public float amplitude = 1.0f; // 振幅
|
||||
public float frequency = 1.0f; // 频率
|
||||
public float speed = 1.0f; // 波形变化速度
|
||||
public int minAmplitude = 1; // 最小振幅
|
||||
public int maxAmplitude = 5; // 最大振幅
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!islist)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EditorAudioManager.Instance.Update(Time.deltaTime);
|
||||
|
||||
|
||||
//if (nowtime <= playtime)
|
||||
////{
|
||||
//// float[] temp = new float[16];
|
||||
//// float[] logSpectrumLevels = new float[16];
|
||||
|
||||
//// analyzer.GetSpectrumLevels(ref temp);
|
||||
//// SplitBandsOnLogScale(ref temp, ref logSpectrumLevels);
|
||||
|
||||
|
||||
//// //for (int i = 0; i < temp.Length; i++)
|
||||
//// //{
|
||||
//// // if (temp[i] * 100 > 10)
|
||||
//// // {
|
||||
//// // temp[i] = Mathf.Clamp((2 + temp[i] * 100), 1, 5);
|
||||
//// // }
|
||||
//// // else
|
||||
//// // {
|
||||
//// // temp[i] = Mathf.Clamp((2 - temp[i] * 100), 1, 5);
|
||||
//// // }
|
||||
//// // //temp[i] = (Mathf.Clamp((10 * Mathf.Log10(temp[i])), 1, 5));
|
||||
//// //}
|
||||
|
||||
//// list.Add(logSpectrumLevels);
|
||||
//// nowtime += Time.deltaTime;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
if (islist)
|
||||
{
|
||||
onPlay(list);
|
||||
islist = false;
|
||||
// EditorAudioManager.Instance.StopAllMusic();
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
EditorAudioManager.Instance.UnregisterAnalyzer(GameObject.Find("Audio(Singleton)"), analyzer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ce5e4df8f826e23428a572d62938043b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 798da0cf3825a2d4b8e9eb81e3467a00
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d17e1971265da15458532aa9d715f948
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using CriWare;
|
||||
using CriWare.Assets;
|
||||
using PhxhSDK;
|
||||
|
||||
//基于Criware的音频控制类
|
||||
public class EditorAudioCriware : AudioBase
|
||||
{
|
||||
private CriAtomSourceForAsset _criAtomSource;
|
||||
private CriAtomAssets _criAtomAssets;
|
||||
private CriAtomAcbAsset _initAcb;
|
||||
private CriAtomCueReference _cue;
|
||||
private GameObject _rootGo;
|
||||
|
||||
private int _cueId = -1;
|
||||
private static int _cueIDs = 0;
|
||||
|
||||
public static int CueIDGen()
|
||||
{
|
||||
return ++_cueIDs;
|
||||
}
|
||||
|
||||
public GameObject RootGo => _rootGo;
|
||||
|
||||
public CriAtomSourceForAsset audioSource
|
||||
{
|
||||
get => _criAtomSource;
|
||||
}
|
||||
protected EditorAudioCriware(CriAtomAcbAsset acbAsset, bool loop, Transform sourceTransform, bool is3D,
|
||||
string cueName, EditorAudio.AudioInfo audioInfo)
|
||||
{
|
||||
|
||||
if (sourceTransform == null)
|
||||
{
|
||||
this.sourceTransform = EditorAudioManager.Instance.initGameObject.transform;
|
||||
_rootGo = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sourceTransform = sourceTransform;
|
||||
_rootGo = sourceTransform.gameObject;
|
||||
is3D = true;
|
||||
}
|
||||
|
||||
this.persist = audioInfo.persist;
|
||||
targetVolume = audioInfo.volume;
|
||||
initTargetVolume = audioInfo.volume;
|
||||
this.volume = audioInfo.volume;
|
||||
tempFadeSeconds = -1;
|
||||
this.fadeInSeconds = audioInfo.fadeInValue;
|
||||
this.fadeOutSeconds = audioInfo.fadeOutValue;
|
||||
|
||||
//playState = PlayState.Stopped;
|
||||
playState = PlayState.Loading;
|
||||
|
||||
//等acb文件加载完成后挂source
|
||||
acbAsset.OnLoaded += OnAcbLoaded(acbAsset, cueName, loop, is3D);
|
||||
}
|
||||
|
||||
private Action<CriAtomAcbAsset> OnAcbLoaded(CriAtomAcbAsset acbAsset, string cueName, bool isLoop = false, bool is3D = false)
|
||||
{
|
||||
|
||||
CreateAudiosource(acbAsset, isLoop, is3D);
|
||||
if (EditorAudioManager.Instance.IsAnalyzer)
|
||||
{
|
||||
_criAtomSource.AttachToAnalyzer(EditorAudioManager.Instance.analyzer);
|
||||
}
|
||||
if (cueName.Length > 0)
|
||||
{
|
||||
PlayByCueName(cueName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Play();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool _GetFreeAudioSource()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CreateAudiosource(CriAtomAcbAsset acbAsset, bool loop = false, bool is3D = false)
|
||||
{
|
||||
_criAtomSource = sourceTransform.gameObject.AddComponent<CriAtomSourceForAsset>();
|
||||
CriAtomCueReference cueReference = new CriAtomCueReference(acbAsset, CueIDGen());//CueIDGen());
|
||||
_criAtomSource.Cue = cueReference;
|
||||
_criAtomSource.loop = loop;
|
||||
_criAtomSource.volume = 1f;
|
||||
_criAtomSource.use3dPositioning = is3D;
|
||||
//_criAtomSource.playOnStart = true;
|
||||
_initAcb = acbAsset;
|
||||
}
|
||||
|
||||
public override void Play(float volume)
|
||||
{
|
||||
if (_criAtomSource == null)
|
||||
{
|
||||
CreateAudiosource(_initAcb, loop);
|
||||
}
|
||||
|
||||
_criAtomSource.Play();
|
||||
playState = PlayState.Playing;
|
||||
|
||||
fadeInterpolater = 0f;
|
||||
onFadeStartVolume = this.volume;
|
||||
targetVolume = volume;
|
||||
}
|
||||
|
||||
public void PlayByCueName(string cueName, bool isLoop = false)
|
||||
{
|
||||
if (_criAtomSource == null)
|
||||
{
|
||||
CreateAudiosource(_initAcb, loop);
|
||||
}
|
||||
|
||||
CriAtomExPlayback playback= _criAtomSource.Play(cueName);
|
||||
DebugUtil.Log("playback" + playback.GetTime());
|
||||
playState = PlayState.Playing;
|
||||
|
||||
fadeInterpolater = 0f;
|
||||
onFadeStartVolume = this.volume;
|
||||
targetVolume = volume;
|
||||
this.loop = isLoop;
|
||||
}
|
||||
|
||||
public override void Play(string cueName, bool isLoop = false)
|
||||
{
|
||||
PlayByCueName(cueName, isLoop);
|
||||
}
|
||||
|
||||
public override void Pause()
|
||||
{
|
||||
_criAtomSource.Pause(true);
|
||||
playState = PlayState.Paused;
|
||||
}
|
||||
|
||||
//继续播放
|
||||
public override void Resume()
|
||||
{
|
||||
_criAtomSource.Pause(false);
|
||||
playState = PlayState.Playing;
|
||||
}
|
||||
|
||||
public void SetPitch(float _pitch)
|
||||
{
|
||||
if (_criAtomSource != null)
|
||||
{
|
||||
_criAtomSource.pitch = _pitch;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetIs3D(bool is3D)
|
||||
{
|
||||
_criAtomSource.use3dPositioning = is3D;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (!_criAtomSource)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
activated = true;
|
||||
|
||||
if (Math.Abs(volume - targetVolume) > 0.01f)
|
||||
{
|
||||
float fadeValue;
|
||||
fadeInterpolater += Time.unscaledDeltaTime;
|
||||
if (volume > targetVolume)
|
||||
{
|
||||
fadeValue = Math.Abs(tempFadeSeconds + 1) > 0.01f ? tempFadeSeconds : fadeOutSeconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
fadeValue = Math.Abs(tempFadeSeconds + 1) > 0.01f ? tempFadeSeconds : fadeInSeconds;
|
||||
}
|
||||
|
||||
volume = Mathf.Lerp(onFadeStartVolume, targetVolume, fadeInterpolater / fadeValue);
|
||||
}
|
||||
else if (Math.Abs(tempFadeSeconds - (-1)) > 0.01)
|
||||
{
|
||||
tempFadeSeconds = -1;
|
||||
}
|
||||
|
||||
switch (audioType)
|
||||
{
|
||||
case AudioType.Music:
|
||||
{
|
||||
_criAtomSource.volume = volume * AudioManager.Instance.GlobalMusicVolume * AudioManager.Instance.GlobalVolume;
|
||||
break;
|
||||
}
|
||||
case AudioType.Sound:
|
||||
{
|
||||
_criAtomSource.volume = volume * AudioManager.Instance.GlobalSoundsVolume * AudioManager.Instance.GlobalVolume;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (volume == 0f && IsStopped)
|
||||
{
|
||||
_criAtomSource.Stop();
|
||||
}
|
||||
|
||||
// Update playing status
|
||||
if (_criAtomSource.status != CriAtomSourceBase.Status.Playing && !Application.isFocused)
|
||||
{
|
||||
//playState = PlayState.Playing;
|
||||
playState = PlayState.Stopped;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 69be55a91cc62df4e9f68c850eea9c2d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using PhxhSDK;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
namespace Gameplay
|
||||
{
|
||||
public class MusicCubeManager : Singlenton<MusicCubeManager>
|
||||
{
|
||||
float nowPlaySpeed;
|
||||
string nowPlayMusicName;
|
||||
public class OneMusicData
|
||||
{
|
||||
public string name;
|
||||
public List<OneFrameData> frameDatas = new List<OneFrameData>();
|
||||
public OneMusicData()
|
||||
{
|
||||
name = "fff";
|
||||
|
||||
for (int i = 0; i < 60; i++)
|
||||
{
|
||||
frameDatas.Add(new OneFrameData());
|
||||
}
|
||||
}
|
||||
public OneMusicData(List<float[]> list, string musicName)
|
||||
{
|
||||
name = musicName;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
frameDatas.Add(new OneFrameData(list[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
public class OneFrameData
|
||||
{
|
||||
public List<int> ColData = new List<int>();
|
||||
public OneFrameData()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
ColData.Add(0);
|
||||
}
|
||||
}
|
||||
public OneFrameData(float[] s)
|
||||
{
|
||||
for (int i = 0; i < s.Length; i++)
|
||||
{
|
||||
ColData.Add(Convert.ToInt16(s[i]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public OneMusicData LoadConfig(string musicName)
|
||||
{
|
||||
// 检查json
|
||||
var savePath = "Assets/Config/UISomeAbout/MainPanelMusicCube/";
|
||||
var saveName = musicName + ".json";
|
||||
var realPath = Application.dataPath + "/Config/UISomeAbout/MainPanelMusicCube/" + saveName;
|
||||
|
||||
// 先判断存不存在
|
||||
if (File.Exists(realPath))
|
||||
{
|
||||
var jsonStr = File.ReadAllText(realPath);
|
||||
return JsonUtility.FromJson<OneMusicData>(jsonStr);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 不存在,进行默认设置
|
||||
EditorUtility.DisplayDialog("提示", "文件不存在,请先录制", "确定");
|
||||
return new OneMusicData();
|
||||
}
|
||||
}
|
||||
public List<float[]> ConvertOneMusicDataToListArray(OneMusicData oneMusicData)
|
||||
{
|
||||
List<float[]> temp = new List<float[]>();
|
||||
for (int i = 0; i < oneMusicData.frameDatas.Count; i++)
|
||||
{
|
||||
float[] temp1 = new float[16];
|
||||
for (int j = 0; j < oneMusicData.frameDatas[i].ColData.Count; j++)
|
||||
{
|
||||
temp1[j] = oneMusicData.frameDatas[i].ColData[j];
|
||||
}
|
||||
temp.Add(temp1);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
public List<float[]> GetGeneralMusicCfg()
|
||||
{
|
||||
return ConvertOneMusicDataToListArray(LoadConfig("General"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c0d9251e01e80a74cb26f68f13ee22cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets.Initialization;
|
||||
using static UI_MainPanelController;
|
||||
|
||||
public class MusicCubeRun : MonoBehaviour
|
||||
{
|
||||
private List<MusicCube> cubeList;
|
||||
public bool isStartRun;
|
||||
private List<float[]> allFrameData;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
InitData();
|
||||
InitCube();
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
cubeList = new List<MusicCube>();
|
||||
isStartRun = false;
|
||||
allFrameData = new List<float[]>();
|
||||
}
|
||||
|
||||
public void StartPlay(List<float[]> musicData)
|
||||
{
|
||||
allFrameData = musicData;
|
||||
isStartRun = true;
|
||||
}
|
||||
private void InitCube()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
cubeList.Add(new MusicCube(transform.Find(string.Format("cube/{0}", i)).gameObject));
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
string temp = "";
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(!isStartRun)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(i>= allFrameData.Count-1)
|
||||
{
|
||||
isStartRun = false;
|
||||
}else
|
||||
{
|
||||
temp = "";
|
||||
RefreshCube(allFrameData[i]);
|
||||
i++;
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
temp += allFrameData[i][j];
|
||||
}
|
||||
DebugUtil.Log("方块为" + temp);
|
||||
}
|
||||
|
||||
}
|
||||
private void RefreshCube(float[] levels)
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
cubeList[i].ShowCube(levels[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f12f3e6639d87e54cbdb8ab8fc6d487e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using cfg.UIInterfaceBannerGoToCfg;
|
||||
using CriWare;
|
||||
using Framework;
|
||||
using Gameplay;
|
||||
using Gameplay.Common;
|
||||
using Gameplay.Level;
|
||||
using Gameplay.Net;
|
||||
using PhxhSDK;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -75,11 +75,10 @@ public class UI_MainPanelController: UIWindow
|
|||
public RawImage RawImage_Scene;
|
||||
public Button GiftCodeBtn;
|
||||
|
||||
private CriAtomExOutputAnalyzer analyzer;
|
||||
private bool isAnalyzerStart = false;
|
||||
private bool isMusicStart = false;
|
||||
|
||||
private List<MusicCube> cubeList = new List<MusicCube>();
|
||||
|
||||
private List<float[]>musicData = new List<float[]>();
|
||||
///Auto Gen End///
|
||||
|
||||
// Use this for initializationf
|
||||
|
|
@ -99,18 +98,19 @@ public class UI_MainPanelController: UIWindow
|
|||
GiftCodeBtn = GetComponent<Button>("Button_DuiHuanMa");
|
||||
BindButton(GiftCodeBtn, OnGiftBtnClick);
|
||||
RawImage_Scene = GetComponent<RawImage>("RawImage_Scene");
|
||||
analyzer = new CriAtomExOutputAnalyzer(NewConfig());
|
||||
InitCube();
|
||||
GetGeneralMusicData();
|
||||
BindButton(Button_Install, OnOpenSettingPanel);
|
||||
|
||||
}
|
||||
CriWare.CriAtomExOutputAnalyzer.Config NewConfig()
|
||||
private void GetGeneralMusicData()
|
||||
{
|
||||
CriWare.CriAtomExOutputAnalyzer.Config config = new CriAtomExOutputAnalyzer.Config();
|
||||
config.enableSpectrumAnalyzer = true;
|
||||
config.numSpectrumAnalyzerBands = 16;
|
||||
|
||||
return config;
|
||||
musicData = MusicCubeManager.Instance.GetGeneralMusicCfg();
|
||||
}
|
||||
|
||||
private void SetNowRefreshTime()
|
||||
{
|
||||
refreshTime = 0.01f;
|
||||
}
|
||||
private async void OnGiftBtnClick()
|
||||
{
|
||||
|
|
@ -135,58 +135,42 @@ public class UI_MainPanelController: UIWindow
|
|||
}
|
||||
}
|
||||
|
||||
float[] levels = new float[16];
|
||||
float refreshTime = 2;
|
||||
float refreshTime = 0.1f;
|
||||
float nowTime = 0;
|
||||
int index;
|
||||
void Update()
|
||||
{
|
||||
//if(!isAnalyzerStart)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
if (!isMusicStart)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(nowTime>=refreshTime)
|
||||
{
|
||||
nowTime = 0;
|
||||
if(index<musicData.Count)
|
||||
{
|
||||
RefreshCube(musicData[index]);
|
||||
index++;
|
||||
}else
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
}else
|
||||
{
|
||||
nowTime += Time.deltaTime;
|
||||
}
|
||||
|
||||
////if(nowTime>=refreshTime)
|
||||
////{
|
||||
//// nowTime = 0;
|
||||
// AudioManager.Instance.analyzer.GetSpectrumLevels(ref levels);
|
||||
// RefreshCube(levels);
|
||||
//}else
|
||||
//{
|
||||
// nowTime += Time.deltaTime;
|
||||
//}
|
||||
////for (int i = 0; i < levels.Length; i++)
|
||||
//{
|
||||
// if (levels[i] * 100 > 10)
|
||||
// {
|
||||
// DebugUtil.Log(2 + levels[i] * 100);
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// DebugUtil.Log(2 -levels[i] * 100);
|
||||
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
private void RefreshCube(float[] levels)
|
||||
{
|
||||
float val = 0;
|
||||
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
val = Mathf.Clamp(levels[i], 0, 3);
|
||||
if (levels[i]*100 > 10)
|
||||
{
|
||||
cubeList[i].ShowCube(2 +val);
|
||||
}
|
||||
else
|
||||
{
|
||||
cubeList[i].ShowCube(2 - val);
|
||||
|
||||
}
|
||||
cubeList[i].ShowCube(levels[i]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -302,14 +286,10 @@ public class UI_MainPanelController: UIWindow
|
|||
await UI_InterfacePreviewManager.Instance.LoadPreviewNode();
|
||||
StartRefresh();
|
||||
InputManager.Instance.OnFingerMoveUI += RotateScene;
|
||||
AudioManager.Instance.RegisterAnalyzer(analyzer);
|
||||
//AudioManager.Instance.RegisterAnalyzer(analyzer);
|
||||
await AudioManager.Instance.PlayAudio("DemoProj_M1");
|
||||
isAnalyzerStart = true;
|
||||
//CriAtomSourceForAsset audioAsset = GameObject.Find("Audio(Singleton)").GetComponent<CriAtomSourceForAsset>();
|
||||
//audioAsset.Stop();
|
||||
|
||||
//audioAsset.AttachToAnalyzer(analyzer);
|
||||
//audioAsset.Play();
|
||||
isMusicStart = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -376,13 +356,25 @@ public class UI_MainPanelController: UIWindow
|
|||
Text_PPMax.text = maxLevel.MaxEnergy.ToString();
|
||||
Text_DamondNum.text = Utils.CommonUtils.NumToEnglish(Actor.Instance.Item.GetItemCount(GLConfig.Inst.data.DiamondItemId));
|
||||
Text_CoinNum.text = Utils.CommonUtils.NumToEnglish(Actor.Instance.Item.GetItemCount(GLConfig.Inst.data.GoldItemId));
|
||||
Text_Time.text = System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString();
|
||||
Text_Time.text = GetNowTime();
|
||||
|
||||
}
|
||||
private string GetNowTime()
|
||||
{
|
||||
string minutes = "";
|
||||
int min = System.DateTime.Now.Minute;
|
||||
if(min>=10)
|
||||
{
|
||||
minutes = min.ToString();
|
||||
}else
|
||||
{
|
||||
minutes = "0" + min.ToString();
|
||||
}
|
||||
return System.DateTime.Now.Hour.ToString()+":"+minutes;
|
||||
}
|
||||
protected override void OnCloseWindow(bool destroy = false)
|
||||
{
|
||||
InputManager.Instance.OnFingerMoveUI -= RotateScene;
|
||||
AudioManager.Instance.UnregisterAnalyzer(GameObject.Find("Audio(Singleton)"),analyzer);
|
||||
UI_InterfacePreviewManager.Instance.ReleasePreviewNode();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 01b35757ef69f0e4ba785ae9b28cc3c6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8b8961cb295cee5409a740d8a2fe3dd4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"name":"DemoProj_M2","frameDatas":[{"ColData":[2,2,3,4,5,4,3,2,1,1,2,3,4,3,2,1]},{"ColData":[4,3,2,1,0,1,2,3,4,5,4,3,2,1,1,1]},{"ColData":[5,4,2,1,2,4,5,3,3,2,2,3,4,3,2,2]},{"ColData":[1,2,3,4,5,4,3,2,1,3,4,5,4,5,1,1]},{"ColData":[2,3,4,3,2,3,4,5,4,3,2,1,2,2,5,2]},{"ColData":[2,3,4,3,2,2,2,3,3,3,3,3,2,2,2,1]},{"ColData":[5,4,3,1,1,3,4,5,4,3,4,5,4,3,2,1]},{"ColData":[2,1,0,3,4,5,4,3,2,1,2,3,4,5,2,2]},{"ColData":[4,2,1,2,4,3,2,1,5,4,3,2,5,3,3,2]},{"ColData":[2,4,3,2,1,2,3,4,5,0,2,3,4,3,2,1]},{"ColData":[3,2,3,4,5,4,3,2,1,2,3,4,5,4,3,3]},{"ColData":[5,4,2,1,2,4,5,4,3,4,5,3,2,1,3,3]},{"ColData":[1,2,3,4,5,4,3,2,1,1,3,4,3,2,3,3]},{"ColData":[3,3,4,5,4,3,2,1,1,1,1,1,2,2,2,3]},{"ColData":[3,4,5,4,3,2,1,2,3,3,2,1,1,2,2,2]},{"ColData":[4,2,1,2,4,5,4,3,2,5,3,1,2,2,2]},{"ColData":[5,4,3,4,3,4,5,4,3,4,5,4,3,1,1,2]}]}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2bc6172138fbf7e4a92309d57296bc05
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 046ea04591ba74a4dbbd92a49b74cbe4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
#if UNITY_EDITOR
|
||||
namespace MusicCubeEditor
|
||||
{
|
||||
using PhxhSDK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class MusicCubeEditorToolManager :Singlenton<MusicCubeEditorToolManager>
|
||||
{
|
||||
const string MusicCubeEditorScene = "Assets/musictest.unity";
|
||||
public string nowPlayMusicName;
|
||||
public void OpenTestScene()
|
||||
{
|
||||
var scene = SceneManager.GetActiveScene();
|
||||
if (scene.path == MusicCubeEditorScene)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorSceneManager.OpenScene(MusicCubeEditorScene);
|
||||
}
|
||||
}
|
||||
public void ChangeDataToJson(List<float[]> list)
|
||||
{
|
||||
OneMusicData data = ConvertListarrayToOneMusicData(list);
|
||||
data.name = nowPlayMusicName;
|
||||
SaveConfig(data);
|
||||
}
|
||||
public void SetNowMusicName(string name)
|
||||
{
|
||||
nowPlayMusicName = name;
|
||||
}
|
||||
public OneMusicData ConvertListarrayToOneMusicData(List<float[]> list)
|
||||
{
|
||||
OneMusicData data = new OneMusicData(list, nowPlayMusicName);
|
||||
return data;
|
||||
}
|
||||
public List<float[]> ConvertOneMusicDataToListArray(OneMusicData oneMusicData)
|
||||
{
|
||||
List<float[]>temp=new List<float[]>();
|
||||
for (int i = 0; i < oneMusicData.frameDatas.Count; i++)
|
||||
{
|
||||
float[] temp1 = new float[16];
|
||||
for (int j = 0; j < oneMusicData.frameDatas[i].ColData.Count; j++)
|
||||
{
|
||||
temp1[j] = oneMusicData.frameDatas[i].ColData[j];
|
||||
}
|
||||
temp.Add(temp1);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
public void SaveConfig(OneMusicData saveData)
|
||||
{
|
||||
// 保存timeline
|
||||
//var director = _cmp.gameObject.GetComponent<PlayableDirector>();
|
||||
//var playAsset = director.playableAsset as TimelineAsset;
|
||||
// 保存json到本地
|
||||
{
|
||||
var json = JsonUtility.ToJson(saveData);
|
||||
var savePath = "Assets/Config/UISomeAbout/MainPanelMusicCube/";
|
||||
var saveName = "music_"+saveData.name + ".json";
|
||||
var fullPath = savePath + "/" + saveName;
|
||||
var realPath = Application.dataPath + fullPath.Substring(6);
|
||||
if (File.Exists(realPath))
|
||||
{
|
||||
//if (VersionControlUtils.IsPathVersioned(fullPath))
|
||||
//{
|
||||
// Provider.Checkout(fullPath, CheckoutMode.Both).Wait();
|
||||
//}
|
||||
File.Delete(realPath);
|
||||
}
|
||||
File.WriteAllText(realPath, json);
|
||||
Debug.Log("json保存成功:" + fullPath);
|
||||
}
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
// 弹出对话框提示
|
||||
EditorUtility.DisplayDialog("提示", "保存成功", "确定");
|
||||
}
|
||||
public OneMusicData LoadConfig(string musicName)
|
||||
{
|
||||
// 检查json
|
||||
var savePath = "Assets/Config/UISomeAbout/MainPanelMusicCube/";
|
||||
var saveName = "music_" + musicName + ".json";
|
||||
var realPath = Application.dataPath + "/Config/UISomeAbout/MainPanelMusicCube/" + saveName;
|
||||
|
||||
// 先判断存不存在
|
||||
if (File.Exists(realPath))
|
||||
{
|
||||
var jsonStr = File.ReadAllText(realPath);
|
||||
return JsonUtility.FromJson<OneMusicData>(jsonStr);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 不存在,进行默认设置
|
||||
EditorUtility.DisplayDialog("提示", "文件不存在,请先录制", "确定");
|
||||
return new OneMusicData();
|
||||
}
|
||||
}
|
||||
|
||||
public class OneMusicData
|
||||
{
|
||||
public string name;
|
||||
public List<OneFrameData> frameDatas = new List<OneFrameData>();
|
||||
public OneMusicData()
|
||||
{
|
||||
name = "fff";
|
||||
|
||||
for (int i = 0; i < 60; i++)
|
||||
{
|
||||
frameDatas.Add(new OneFrameData());
|
||||
}
|
||||
}
|
||||
public OneMusicData(List<float[]> list, string musicName)
|
||||
{
|
||||
name = musicName;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
frameDatas.Add(new OneFrameData(list[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
|
||||
public class OneFrameData
|
||||
{
|
||||
public List<int> ColData = new List<int>();
|
||||
public OneFrameData()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
ColData.Add(0);
|
||||
}
|
||||
}
|
||||
public OneFrameData(float[] s)
|
||||
{
|
||||
for (int i = 0; i < s.Length; i++)
|
||||
{
|
||||
ColData.Add(Convert.ToInt16(s[i]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 316b2ce706352a140911a738e2acc1f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using UnityEditor;
|
||||
using MusicCubeEditor;
|
||||
public static class MusicCubeTool
|
||||
{
|
||||
//[MenuItem("Tools/MusicCube工具", false, (int)NLDMenuID.MusicCube)]
|
||||
//public static void MusicCubeToolsConfig()
|
||||
//{
|
||||
// MusicCubeWindow.ShowWindow();
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4d01a58e50a24e54aa51c6ee46395332
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
#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
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 244c3835f79345c4592479037f576e01
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue