216 lines
5.2 KiB
C#
216 lines
5.2 KiB
C#
// using System.Collections;
|
|
// using System.Collections.Generic;
|
|
// using CriWare;
|
|
// //using CriWare.Assets;
|
|
// using Cysharp.Threading.Tasks;
|
|
// using Framework;
|
|
// using PhxhSDK;
|
|
// using UnityEditor;
|
|
// using UnityEngine;
|
|
//
|
|
// public class AudioEditorMgr : Editor
|
|
// {
|
|
// private Dictionary<int, EditorAudio> _audioDic;
|
|
// private List<int> _cacheAudios;
|
|
// private List<int> _playingAudios;
|
|
// private List<int> _toBeRemoved;
|
|
//
|
|
// private static AudioEditorMgr _instance;
|
|
// public static AudioEditorMgr Instance
|
|
// {
|
|
// get
|
|
// {
|
|
// if (_instance == null)
|
|
// {
|
|
// _instance = new AudioEditorMgr();
|
|
// _instance.Init();
|
|
// }
|
|
//
|
|
// return _instance;
|
|
// }
|
|
// }
|
|
//
|
|
// public CriAtomAcbAsset acbAsset;
|
|
//
|
|
// private void Init()
|
|
// {
|
|
// _cacheAudios = new List<int>();
|
|
// _playingAudios = new List<int>();
|
|
// _toBeRemoved = new List<int>();
|
|
// _audioDic = new Dictionary<int, EditorAudio>();
|
|
//
|
|
// //EditorAudio.LoadAcb();
|
|
// }
|
|
//
|
|
// public void LoadAudios(int playerId)
|
|
// {
|
|
//
|
|
// }
|
|
//
|
|
// public void Release()
|
|
// {
|
|
// _instance = null;
|
|
// }
|
|
//
|
|
// public void LogicUpdate()
|
|
// {
|
|
// for (int i = 0; i < _playingAudios.Count; i++)
|
|
// {
|
|
// var id = _playingAudios[i];
|
|
// if (_audioDic.TryGetValue(id, out var audio))
|
|
// {
|
|
// if (audio.CriAtom)
|
|
// {
|
|
// if (audio.IsStopped())
|
|
// {
|
|
// _toBeRemoved.Add(id);
|
|
// }
|
|
// else
|
|
// {
|
|
// audio.Update();
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
// for (int i = 0; i < _toBeRemoved.Count; i++)
|
|
// {
|
|
// if (_audioDic.TryGetValue(_toBeRemoved[i], out var audio))
|
|
// {
|
|
// _playingAudios.Remove(_toBeRemoved[i]);
|
|
// _cacheAudios.Add(_toBeRemoved[i]);
|
|
// //_audioDic.Remove(_toBeRemoved[i]);
|
|
// }
|
|
//
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// public class EditorAudio
|
|
// {
|
|
// public int ID => _id;
|
|
// public CriAtomSourceForAsset CriAtom => _criAtom;
|
|
// public int PlayerID => _playerID;
|
|
// public GameObject BindObj => _bindObj;
|
|
//
|
|
// public static int AudioCount;
|
|
// public static CriAtomAcbAsset AcbAsset;
|
|
// private static bool _isLoading;
|
|
//
|
|
// public enum PlayState
|
|
// {
|
|
// Playing,
|
|
// Pause,
|
|
// Stop
|
|
// }
|
|
//
|
|
// private int _id;
|
|
// private string _audioName;
|
|
// private CriAtomSourceForAsset _criAtom;
|
|
// private PlayState _state;
|
|
// private int _playerID;
|
|
// private GameObject _bindObj;
|
|
//
|
|
//
|
|
// public EditorAudio(string audioName, int playerID, GameObject go, bool is3D = false, bool loop = false)
|
|
// {
|
|
// Init(audioName, playerID, go);
|
|
// CreateAudioSource(is3D, loop);
|
|
// }
|
|
//
|
|
// private static UniTask CheckIsLoading()
|
|
// {
|
|
// if (_isLoading)
|
|
// {
|
|
// UniTask.NextFrame();
|
|
// }
|
|
//
|
|
// return default;
|
|
// }
|
|
//
|
|
// public void Play()
|
|
// {
|
|
// _criAtom.Play();
|
|
// _state = PlayState.Playing;
|
|
// }
|
|
//
|
|
// public void Play(string cueName)
|
|
// {
|
|
// _criAtom.Play(cueName);
|
|
// _state = PlayState.Playing;
|
|
// }
|
|
//
|
|
// public void Stop()
|
|
// {
|
|
// _criAtom.Stop();
|
|
// _state = PlayState.Stop;
|
|
// }
|
|
//
|
|
// public void Pause()
|
|
// {
|
|
// if (IsPlaying())
|
|
// {
|
|
// _criAtom.Pause(true);
|
|
// _state = PlayState.Pause;
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
// public void Resume()
|
|
// {
|
|
// if (IsPause())
|
|
// {
|
|
// _criAtom.Pause(false);
|
|
// _state = PlayState.Playing;
|
|
// }
|
|
// }
|
|
//
|
|
// public bool IsPlaying()
|
|
// {
|
|
// return _state == PlayState.Playing;
|
|
// }
|
|
//
|
|
// public bool IsStopped()
|
|
// {
|
|
// return _state == PlayState.Stop;
|
|
// }
|
|
//
|
|
// public bool IsPause()
|
|
// {
|
|
// return _state == PlayState.Pause;
|
|
// }
|
|
//
|
|
// public void Update()
|
|
// {
|
|
// if (_criAtom.status == CriAtomSourceBase.Status.Stop)
|
|
// {
|
|
// _state = PlayState.Stop;
|
|
// }
|
|
// }
|
|
//
|
|
// public void Init(string audioName, int playerID, GameObject go)
|
|
// {
|
|
// _id = AudioCount++;
|
|
// _audioName = audioName;
|
|
// _playerID = playerID;
|
|
// _bindObj = go;
|
|
// }
|
|
//
|
|
// private async void CreateAudioSource(bool is3D, bool loop = false)
|
|
// {
|
|
// await CheckIsLoading();
|
|
// var criAtom = _bindObj.GetComponent<CriAtomSourceForAsset>();
|
|
// if (criAtom)
|
|
// {
|
|
// _criAtom = criAtom;
|
|
// }
|
|
// else
|
|
// {
|
|
// _criAtom = _bindObj.AddComponent<CriAtomSourceForAsset>();
|
|
// }
|
|
// _criAtom.volume = 1f;
|
|
// _criAtom.use3dPositioning = is3D;
|
|
// _criAtom.loop = loop;
|
|
// }
|
|
// } |