diff --git a/ProjectNLD/Assets/Audio/Music/CueSheet_BGM.acb.meta b/ProjectNLD/Assets/Audio/Music/CueSheet_BGM.acb.meta index 49ba5fcd20c..29970ee7ea3 100644 --- a/ProjectNLD/Assets/Audio/Music/CueSheet_BGM.acb.meta +++ b/ProjectNLD/Assets/Audio/Music/CueSheet_BGM.acb.meta @@ -9,7 +9,7 @@ ScriptedImporter: assetBundleVariant: script: {fileID: 11500000, guid: d286586ba24ad438aac133d47a3e12b0, type: 3} implementation: - rid: 5872427010005925889 + rid: 1207811832167792640 awb: {instanceID: 0} assetInfo: awb: {fileID: -6750239444755058063, guid: 457c267486916ea4392d6e204aa934be, type: 3} @@ -17,6 +17,6 @@ ScriptedImporter: references: version: 2 RefIds: - - rid: 5872427010005925889 - type: {class: CriSerializedBytesAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor} + - rid: 1207811832167792640 + type: {class: CriStreamingFolderAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor} data: diff --git a/ProjectNLD/Assets/Audio/Music/CueSheet_SE.acb.meta b/ProjectNLD/Assets/Audio/Music/CueSheet_SE.acb.meta index 9af74dd65e3..e050257f9a2 100644 --- a/ProjectNLD/Assets/Audio/Music/CueSheet_SE.acb.meta +++ b/ProjectNLD/Assets/Audio/Music/CueSheet_SE.acb.meta @@ -9,7 +9,7 @@ ScriptedImporter: assetBundleVariant: script: {fileID: 11500000, guid: d286586ba24ad438aac133d47a3e12b0, type: 3} implementation: - rid: 1207811425366179840 + rid: 1207811832167792642 awb: {instanceID: 0} assetInfo: awb: {fileID: -6750239444755058063, guid: dcc77d0a8f113b44c90ef6ee6abebb8c, type: 3} @@ -17,6 +17,6 @@ ScriptedImporter: references: version: 2 RefIds: - - rid: 1207811425366179840 - type: {class: CriSerializedBytesAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor} + - rid: 1207811832167792642 + type: {class: CriStreamingFolderAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor} data: diff --git a/ProjectNLD/Assets/Audio/Music/CueSheet_SE.acf.meta b/ProjectNLD/Assets/Audio/Music/CueSheet_SE.acf.meta index 7670d28b32e..57f35796f88 100644 --- a/ProjectNLD/Assets/Audio/Music/CueSheet_SE.acf.meta +++ b/ProjectNLD/Assets/Audio/Music/CueSheet_SE.acf.meta @@ -9,10 +9,10 @@ ScriptedImporter: assetBundleVariant: script: {fileID: 11500000, guid: 7cb389209abe442de834ce7a701e2513, type: 3} implementation: - rid: 1207811425366179841 + rid: 1207811832167792643 references: version: 2 RefIds: - - rid: 1207811425366179841 - type: {class: CriSerializedBytesAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor} + - rid: 1207811832167792643 + type: {class: CriStreamingFolderAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor} data: diff --git a/ProjectNLD/Assets/Audio/Music/CueSheet_SE.awb.meta b/ProjectNLD/Assets/Audio/Music/CueSheet_SE.awb.meta index 1ea4488be28..c173a2ced9c 100644 --- a/ProjectNLD/Assets/Audio/Music/CueSheet_SE.awb.meta +++ b/ProjectNLD/Assets/Audio/Music/CueSheet_SE.awb.meta @@ -9,10 +9,10 @@ ScriptedImporter: assetBundleVariant: script: {fileID: 11500000, guid: 503c02039ceed4218bb78fdac1d6a536, type: 3} implementation: - rid: 1000 + rid: 1207811832167792644 references: version: 2 RefIds: - - rid: 1000 + - rid: 1207811832167792644 type: {class: CriStreamingFolderAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor} data: diff --git a/ProjectNLD/Assets/Audio/Music/CueSheet_VOICE.acb.meta b/ProjectNLD/Assets/Audio/Music/CueSheet_VOICE.acb.meta index 69ed634ae3e..a2883afac5c 100644 --- a/ProjectNLD/Assets/Audio/Music/CueSheet_VOICE.acb.meta +++ b/ProjectNLD/Assets/Audio/Music/CueSheet_VOICE.acb.meta @@ -9,7 +9,7 @@ ScriptedImporter: assetBundleVariant: script: {fileID: 11500000, guid: d286586ba24ad438aac133d47a3e12b0, type: 3} implementation: - rid: 5872427010005925888 + rid: 1207811832167792641 awb: {instanceID: 0} assetInfo: awb: {fileID: -6750239444755058063, guid: cdfbd6198f1bc3a46b6562752dd2fb00, type: 3} @@ -17,6 +17,6 @@ ScriptedImporter: references: version: 2 RefIds: - - rid: 5872427010005925888 - type: {class: CriSerializedBytesAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor} + - rid: 1207811832167792641 + type: {class: CriStreamingFolderAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor} data: diff --git a/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCri.cs b/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCri.cs index 9e438fb37c9..0fa95ba7a60 100644 --- a/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCri.cs +++ b/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCri.cs @@ -14,6 +14,8 @@ public class AudioCri: AudioBase private bool _isSpeak; private int _playID; + public CriAtomExPlayback CriAtomExPlayback; + #region Construct public AudioCri(AudioType audioType, GameObject rootGo, GameObject posGo, AudioInfo audioInfo, @@ -23,6 +25,7 @@ public class AudioCri: AudioBase _rootGo = rootGo; _posGo = posGo; _criAtomSource = _GetSource(); + _criAtomSource.volume = GlobalVolume; _isSpeak = audioInfo.isSpeak; } @@ -98,12 +101,12 @@ public class AudioCri: AudioBase public override void Pause() { - + _criAtomSource.Pause(true); } public override void Resume() { - + _criAtomSource.Pause(false); } public override void Play(float volume) @@ -123,17 +126,17 @@ public class AudioCri: AudioBase private void _SetMusicVolume() { - _criAtomSource.volume = volume * GlobalMusicVolume * GlobalVolume; + _criAtomSource.volume = GlobalMusicVolume * GlobalVolume; } private void _SetSoundVolume() { - _criAtomSource.volume = volume * GlobalSoundVolume * GlobalVolume; + _criAtomSource.volume = GlobalSoundVolume * GlobalVolume; } private void _SetSpeakVolume() { - _criAtomSource.volume = volume * GlobalSpeakVolume * GlobalVolume; + _criAtomSource.volume = GlobalSpeakVolume * GlobalVolume; } private void _SetIs3D(bool is3D) @@ -154,7 +157,7 @@ public class AudioCri: AudioBase { _criAtomSource.cueSheet = cueSheet; _criAtomSource.cueName = cueName; - _criAtomSource.Play(); + CriAtomExPlayback = _criAtomSource.Play(); } public void SetIs3D(bool is3D = false) @@ -179,5 +182,30 @@ public class AudioCri: AudioBase _posGo = null; _SetIs3D(false); } + + + public void SetPos(Vector3 position) + { + _rootGo.transform.position = position; + } + + public void SetIsLoop(bool isLoop) + { + _criAtomSource.loop = isLoop; + } + + public void SetIsSpeak(bool isSpeak) + { + _isSpeak = isSpeak; + } + + public string GetCueSheetName() + { + if (_criAtomSource) + { + return _criAtomSource.cueSheet; + } + return ""; + } #endregion } \ No newline at end of file diff --git a/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCriManager.cs b/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCriManager.cs index 1a9ea445a9b..44d66185fb5 100644 --- a/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCriManager.cs +++ b/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCriManager.cs @@ -8,10 +8,13 @@ using AudioType = PhxhSDK.AudioBase.AudioType; public class AudioCriManager: Singlenton, IStart, IInitable, IUpdatable, IAudioPlay { + public GameObject initGameObject; public GameObject AudioRoot; public GameObject CriAtomRoot; public CriAtom CriAtom; public ClipType curClipType; + + private AudioInst _bgmAudio; public enum EPlayType { @@ -34,9 +37,74 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU #region Property - public float GlobalSoundsVolume; - public float GlobalSpeakVolume; - public float GlobalMusicsVolume; + private float _vol = 1f; + + public float GlobalSoundsVolume + { + get => AudioCri.GlobalSoundVolume; + set => AudioCri.GlobalSoundVolume = value; + } + public float GlobalSpeakVolume{ + get => AudioCri.GlobalSpeakVolume; + set => AudioCri.GlobalSpeakVolume = value; + } + + public float GlobalMusicVolume { + get => AudioCri.GlobalMusicVolume; + set => AudioCri.GlobalMusicVolume = value; + } + + public float GlobalVolume + { + get => AudioCri.GlobalVolume; + set => AudioCri.GlobalVolume = value; + } + + public bool GlobalIsOpenSpeak; + + public AudioInst BgmAudio => _bgmAudio; + + public CriAtomExOutputAnalyzer analyzer=null; + public bool IsAnalyzer = false; + + +#endregion + +#region Analyze + + //在播放之前注册 + public CriAtomExOutputAnalyzer RegisterAnalyzer()//CriAtomExOutputAnalyzer s + { + IsAnalyzer = true; + if (analyzer == null) + { + analyzer = new(NewAnalyzerConfig()); + } + return analyzer; + //analyzer = s; + } + + public void UnregisterAnalyzer()//CriAtomExOutputAnalyzer s + { + //s.DetachExPlayer(); + IsAnalyzer = false; + //analyzer = null; + } + + /// + /// 获取音频输出分析器配置 + /// + /// + private CriAtomExOutputAnalyzer.Config NewAnalyzerConfig() + { + CriAtomExOutputAnalyzer.Config config = new() + { + enableSpectrumAnalyzer = true, // 开启频谱分析 + numSpectrumAnalyzerBands = 16, // 频谱分析数量SPECTRUM_SAMPLES_NUMBER + }; + + return config; + } #endregion @@ -51,25 +119,20 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU AudioRoot = new GameObject(); AudioRoot.name = "Audio(Singleton)"; Object.DontDestroyOnLoad(AudioRoot); - + if (curClipType == ClipType.CriwareClip) { _criError = new GameObject(); - _criError.name = "CriwareError"; + _criError.name = "CriwareError"; _criError.AddComponent(); Object.DontDestroyOnLoad(_criError); } - + CriAtomRoot = GameObject.Find("CriAtom"); CriAtom = CriAtomRoot.GetComponent(); Object.DontDestroyOnLoad(CriAtomRoot); - - - _soundAudioDic = new Dictionary(); - _musicAudioDic = new Dictionary(); - _allAudioDic = new Dictionary(); - - // CriAtomRoot = new GameObject() + } + // CriAtomRoot = new GameObject() // { // name = "CriAtom" // }; @@ -93,12 +156,15 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU // }; // go.transform.SetParent(AudioRoot.transform); // } - } } public void Init() { - + _soundAudioDic = new Dictionary(); + _musicAudioDic = new Dictionary(); + _allAudioDic = new Dictionary(); + _soundAudioObj = new(); + _musicAudioObj = new(); } public void Release() @@ -131,9 +197,66 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU #region LoadAsset - private void LoadAcb(string name) + private string _GetCriPath(string name) { + var commonStr = "CueSheet_"; + var strArr = name.Split('_'); + var pre = strArr[0]; + if (pre != null) + { + if (pre == "Voice") + { + return commonStr + "VOICE"; + } + + if (pre == "skill") + { + return commonStr + "SE"; + } + + if (pre == "bgm") + { + return commonStr + "BGM"; + } + } + return null; + } + + private string _GetAcbPath(string name) + { + var path = _GetCriPath(name); + if (path == null) + { + DebugUtil.LogError($"获取不到对应的ACB文件,key: {name}"); + return ""; + } + + return path + ".acb"; + } + + private string _GetAwbPath(string name) + { + var path = _GetCriPath(name); + if (path == null) + { + DebugUtil.LogError($"获取不到对应的AWB文件,key: {name}"); + return ""; + } + + return path + ".awb"; + } + + private string _GetAcfPath(string name) + { + var path = _GetCriPath(name); + if (path == null) + { + DebugUtil.LogError($"获取不到对应的ACF文件,key: {name}"); + return ""; + } + + return path + ".acf"; } #endregion @@ -171,7 +294,7 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU var dic = _GetAudioDic(audioType); if (dic != null) { - foreach (var kv in _soundAudioDic) + foreach (var kv in dic) { var audio = kv.Value; if (audio.IsStopped) @@ -192,7 +315,21 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU }; rootGo.transform.SetParent(AudioRoot.transform); var audio = new AudioInst(audioType, rootGo, null); - rootGo.name += audio.audioID; + + if (audioType == AudioBase.AudioType.Music) + { + rootGo.name = "music"; + rootGo.name += audio.audioID; + _musicAudioDic.TryAdd(audio.audioID, audio); + _musicAudioObj.Add(rootGo); + } + if (audioType == AudioBase.AudioType.Sound) + { + rootGo.name = "Sound"; + rootGo.name += audio.audioID; + _soundAudioDic.TryAdd(audio.audioID, audio); + _soundAudioObj.Add(rootGo); + } return audio; } @@ -221,26 +358,31 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU #region Play + /// + /// 调用接口,传obj + /// + /// + /// + /// + /// private int _PlayAudio(string key, EPlayType type, GameObject posObj = null) { - // var audioCfg = TableManager.Instance.Tables.Audios.GetByKey(key); - // if (audioCfg == null) - // { - // DebugUtil.LogError($"无法获取音频表配置,key:{key}"); - // return -1; - // } if (CriAtom) { - if (CriAtom.GetCueSheetInternal(key) == null) + var cueSheetName = _GetCriPath(key); + if (CriAtom.GetCueSheetInternal(cueSheetName) == null) { - if (key.Contains("skill_")) + var acbPath = _GetAcbPath(key); + var awbPath = _GetAwbPath(key); + if (string.IsNullOrEmpty(acbPath) || string.IsNullOrEmpty(awbPath)) { - CriAtom.AddCueSheet(key, "CueSheet_SE.acb", "CueSheet_SE.awb", null); + return -1; } + CriAtom.AddCueSheet(cueSheetName, acbPath, awbPath, null); } } - string path = "CueSheet_VOICE"; + string path = _GetCriPath(key); switch (type) { @@ -252,6 +394,55 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU { return _PlaySound(key, path, posObj); } + case EPlayType.Speak: + { + return _PlaySpeakSound(key, path, posObj); + } + default: break; + } + + return -1; + } + + /// + /// 调用接口,传位置 + /// + /// + /// + /// + /// + private int _PlayAudio(string key, EPlayType type, Vector3 pos) + { + if (CriAtom) + { + if (CriAtom.GetCueSheetInternal(key) == null) + { + var acbPath = _GetAcbPath(key); + var awbPath = _GetAwbPath(key); + if (string.IsNullOrEmpty(acbPath) || string.IsNullOrEmpty(awbPath)) + { + return -1; + } + CriAtom.AddCueSheet(key, acbPath, awbPath, null); + } + } + + string path = _GetCriPath(key); + + switch (type) + { + case EPlayType.Music: + { + return _PlayMusic(key, path, pos); + } + case EPlayType.Sound: + { + return _PlaySound(key, path, pos); + } + case EPlayType.Speak: + { + return _PlaySpeakSound(key, path, pos); + } default: break; } @@ -260,6 +451,10 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU private int _PlayMusic(string key, string path, GameObject posObj = null) { + if (_bgmAudio != null) + { + _bgmAudio.Stop(); + } AudioInfo audioInfo = new AudioInfo() { persist = true, @@ -268,10 +463,36 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU fadeOutValue = 0.3f, }; var audio = _GetUsableAudio(AudioBase.AudioType.Music); - if (posObj != null) + audio.SetPosObj(posObj); + audio.SetIsSpeak(false); + audio.SetIsLoop(true); + if (_bgmAudio != null && _bgmAudio != audio) { - + _bgmAudio.Stop(); } + audio.Play(path, key); + _bgmAudio = audio; + return -1; + } + + private int _PlayMusic(string key, string path, Vector3 pos) + { + if (_bgmAudio != null) + { + _bgmAudio.Stop(); + } + AudioInfo audioInfo = new AudioInfo() + { + persist = true, + volume = 1, + fadeInValue = 0.3f, + fadeOutValue = 0.3f, + }; + var audio = _GetUsableAudio(AudioBase.AudioType.Music); + audio.SetPos(pos); + audio.SetIsSpeak(false); + audio.SetIsLoop(true); + audio.Play(path, key); return -1; } @@ -287,10 +508,65 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU var audio = _GetUsableAudio(AudioBase.AudioType.Sound); audio.SetPosObj(posObj); + audio.SetIsSpeak(false); + audio.SetIsLoop(false); audio.Play(path, key); return -1; } + + private int _PlaySound(string key, string path, Vector3 pos) + { + AudioInfo audioInfo = new AudioInfo() + { + persist = true, + volume = 1, + fadeInValue = 0.3f, + fadeOutValue = 0.3f, + }; + var audio = _GetUsableAudio(AudioBase.AudioType.Sound); + audio.SetPos(pos); + audio.SetIsLoop(false); + audio.SetIsSpeak(false); + audio.Play(path, key); + return -1; + } + + private int _PlaySpeakSound(string key, string path, GameObject posObj = null) + { + AudioInfo audioInfo = new AudioInfo() + { + persist = true, + volume = 1, + fadeInValue = 0.3f, + fadeOutValue = 0.3f, + }; + + var audio = _GetUsableAudio(AudioBase.AudioType.Sound); + audio.SetPosObj(posObj); + audio.SetIsSpeak(true); + audio.SetIsLoop(false); + audio.Play(path, key); + + return -1; + } + + private int _PlaySpeakSound(string key, string path, Vector3 pos) + { + AudioInfo audioInfo = new AudioInfo() + { + persist = true, + volume = 1, + fadeInValue = 0.3f, + fadeOutValue = 0.3f, + }; + var audio = _GetUsableAudio(AudioBase.AudioType.Sound); + audio.SetPos(pos); + audio.SetIsLoop(false); + audio.SetIsSpeak(true); + audio.Play(path, key); + return -1; + } #endregion #region API @@ -299,8 +575,113 @@ public class AudioCriManager: Singlenton, IStart, IInitable, IU { return _PlayAudio(key, type, posObj); } + + public int PlayAudio(string key, EPlayType type, Vector3 pos) + { + return _PlayAudio(key, type, pos); + } + public int PlayAudio() + { + return -1; + } + + public AudioInst GetAudioByID(EPlayType audioType, int id) + { + if (audioType == EPlayType.Music) + { + if (!_musicAudioDic.ContainsKey(id)) + { + return null; + } + + return _musicAudioDic[id]; + } + + if (audioType == EPlayType.Sound || audioType == EPlayType.Speak) + { + if (!_soundAudioDic.ContainsKey(id)) + { + return null; + } + + return _soundAudioDic[id]; + } + + return null; + } + + public void StopMusicById(int audioID) + { + if (audioID >= 0) + { + if(_musicAudioDic.TryGetValue(audioID, out var audio)) + { + audio.Stop(); + } + } + } + + public void StopAllMusic() + { + if (_bgmAudio != null) + { + _bgmAudio.Stop(); + } + // foreach (var kv in _musicAudioDic) + // { + // var audio = kv.Value; + // audio.Stop(); + // } + } + + public void StopAllSounds() + { + foreach (var kv in _soundAudioDic) + { + var audio = kv.Value; + audio.Stop(); + } + } + + public void StopAll() + { + foreach (var kv in _soundAudioDic) + { + var audio = kv.Value; + audio.Stop(); + } + } + + public void ResumeAllMusic() + { + + if (_bgmAudio != null) + { + _bgmAudio.Resume(); + } + } + + public void StopBGM() + { + _bgmAudio.Stop(); + } + + public void AfterSwitchMainCamera(Camera camera) + { + var listener = camera.GetComponent(); + if (!listener) + { + camera.gameObject.AddComponent(); + } + } + + public CriAtomExAcb GetAcb(string cueSheetName) + { + return CriAtom.GetAcb(cueSheetName); + } #endregion + } public class AudioInst : AudioCri diff --git a/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCriwareMgr.cs b/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCriwareMgr.cs index 6a0806e8288..e3aa6e0b3a1 100644 --- a/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCriwareMgr.cs +++ b/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioCriwareMgr.cs @@ -75,19 +75,19 @@ using Constants = Framework.Constants; curClipType = ClipType.CriwareClip; initGameObject = new GameObject(); - initGameObject.name = "Audio(Singleton)"; + initGameObject.name = "AudioOld(Singleton)"; //initGameObject.hideFlags = HideFlags.HideInHierarchy; // Make instance persistent. Object.DontDestroyOnLoad(initGameObject); - Object.DontDestroyOnLoad(GameObject.Find("CriWareLibraryInitializer")); + //Object.DontDestroyOnLoad(GameObject.Find("CriWareLibraryInitializer")); //#if UNITY_EDITOR - if (curClipType == ClipType.CriwareClip) - { - _criError = new GameObject(); - _criError.name = "CriwareError"; - _criError.AddComponent(); - Object.DontDestroyOnLoad(_criError); - } + // if (curClipType == ClipType.CriwareClip) + // { + // _criError = new GameObject(); + // _criError.name = "CriwareError"; + // _criError.AddComponent(); + // Object.DontDestroyOnLoad(_criError); + // } _rootGoList = new List(); _audioDic = new Dictionary(); diff --git a/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioManager.cs b/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioManager.cs index 57ad8664e82..ea4fabaa671 100644 --- a/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioManager.cs +++ b/ProjectNLD/Assets/Code/Scripts/Framework/Audio/AudioManager.cs @@ -7,7 +7,8 @@ using UnityEngine; public class AudioManager: Singlenton, IStart, IInitable, IUpdatable, IAudioPlay { - private AudioCriwareManager _audioMgrObj = new(); + private AudioCriManager _audioMgrObj = new(); + private AudioCriwareManager _audioMgrOldObj = new(); public GameObject initGameObject; @@ -26,10 +27,15 @@ public class AudioManager: Singlenton, IStart, IInitable, IUpdatab } } - public AudioCriwareManager AudioMgrObj + public AudioCriManager AudioMgrObj { get { return _audioMgrObj; } } + + public AudioCriwareManager AudioOldMgrObj + { + get { return _audioMgrOldObj; } + } private void AfterSwitchCamera(bool isRegister = true) { @@ -59,7 +65,7 @@ public class AudioManager: Singlenton, IStart, IInitable, IUpdatab public void Start() { _audioMgrObj.Start(); - initGameObject = _audioMgrObj.initGameObject; + initGameObject = initGameObject; } public void Update(float dt) @@ -105,29 +111,47 @@ public class AudioManager: Singlenton, IStart, IInitable, IUpdatab { GlobalSoundsVolume = isEnable ? 1 : 0; } - public async UniTask PlayAudio(string key, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound, GameObject posObj = null) + + public CriAtomExAcb GetAcb(string cueSheetName) { - if (DisableAudio) return 0; - return await _audioMgrObj.PlayAudio(key, type, posObj); + return _audioMgrObj.GetAcb(cueSheetName); + } + + #region 流式播放 + + public int PlayAudio(string key, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound, GameObject posObj = null) + { + return _audioMgrObj.PlayAudio(key, type, posObj); + } + + #endregion + // public async UniTask PlayAudio(string key, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound, GameObject posObj = null) + // { + // if (DisableAudio) return 0; + // return await _audioMgrObj.PlayAudio(key, type, posObj); + // } + + // public async UniTask PlayAudio(string key, Vector3 pos, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound) + // { + // if (DisableAudio) return 0; + // return await _audioMgrObj.PlayAudio(key, type, pos); + // } + + public async UniTask PlayAudioOld(int id, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound, GameObject posObj = null) + { + // if (DisableAudio) return 0; + // return await _audioMgrOldObj.PlayAudio(id, type, posObj); + Debug.Log("更换流式播放后,Key值需要修改为String,详情参考AudioSourceConfig"); + return -1; } - public async UniTask PlayAudio(string key, Vector3 pos, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound) + public async UniTask PlayAudioOld(int id, Vector3 pos, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound) { - if (DisableAudio) return 0; - return await _audioMgrObj.PlayAudio(key, type, pos); - } - - public async UniTask PlayAudio(int id, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound, GameObject posObj = null) - { - if (DisableAudio) return 0; - return await _audioMgrObj.PlayAudio(id, type, posObj); - } - - public async UniTask PlayAudio(int id, Vector3 pos, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound) - { - if (DisableAudio) return 0; - DebugUtil.Log("Test"); - return await _audioMgrObj.PlayAudio(id, type, pos); + // if (DisableAudio) return 0; + // DebugUtil.Log("Test"); + // return await _audioMgrOldObj.PlayAudio(id, type, pos); + Debug.Log("更换流式播放后,Key值需要修改为String,详情参考AudioSourceConfig"); + return -1; } public void StopMusicById(int id) @@ -173,7 +197,13 @@ public class AudioManager: Singlenton, IStart, IInitable, IUpdatab _audioMgrObj.StopAll(); } - public Audio GetAudioByID(AudioType audioType, int id) + // public Audio GetAudioByID(AudioType audioType, int id) + // { + // if (DisableAudio) return null; + // return _audioMgrObj.GetAudioByID(audioType, id); + // } + + public AudioInst GetAudioByID(AudioCriManager.EPlayType audioType, int id) { if (DisableAudio) return null; return _audioMgrObj.GetAudioByID(audioType, id); diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Audio/AlbumManager.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Audio/AlbumManager.cs index 5a16e0a1900..d0dde2e48bb 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Audio/AlbumManager.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Audio/AlbumManager.cs @@ -394,7 +394,7 @@ public class AlbumManager : Singlenton { audioIndex = 0; } - await AudioManager.Instance.PlayAudio(playList[audioIndex]); + await AudioManager.Instance.PlayAudioOld(playList[audioIndex]); curMusicKey = TableManager.Instance.Tables.Audios.GetByID(playList[audioIndex]).Key; SetCurAlbum(albumID, audioIndex); @@ -448,11 +448,11 @@ public class AlbumManager : Singlenton var _bgmAudio = AudioManager.Instance.AudioMgrObj.BgmAudio; if (_bgmAudio != null) { - if (_bgmAudio.CriAtomPlayback.GetTime() < 0) + if (_bgmAudio.CriAtomExPlayback.GetTime() < 0) { DebugUtil.LogError("指定音频已被删除!!!"); } - return _bgmAudio.CriAtomPlayback.GetTime() / 1000f; + return _bgmAudio.CriAtomExPlayback.GetTime() / 1000f; } else { @@ -473,6 +473,7 @@ public class AlbumManager : Singlenton { //string key = AlbumManager.Instance.curMusicKey; DataAudio audioData; + var cueSheetName = _bgmAudio.GetCueSheetName(); audioData = TableManager.Instance.Tables.Audios.GetByKey(key); if (audioData == null) @@ -480,7 +481,7 @@ public class AlbumManager : Singlenton DebugUtil.LogError("==== 播放的音频不存在!!!音频Key: {0}", key); return 0; } - if (_bgmAudio.AcbAsset.Handle.GetCueInfo(audioData.CueID, out CriAtomEx.CueInfo info)) + if (AudioManager.Instance.GetAcb(cueSheetName).GetCueInfo(audioData.CueID, out CriAtomEx.CueInfo info)) { if (info.length <= 0) { @@ -524,7 +525,8 @@ public class AlbumManager : Singlenton DebugUtil.LogError("==== 播放的音频不存在!!!音频Key: {0}", ID); return 0; } - if (_bgmAudio.AcbAsset.Handle.GetCueInfo(audioData.CueID, out CriAtomEx.CueInfo info)) + var cueSheetName = _bgmAudio.GetCueSheetName(); + if (AudioManager.Instance.GetAcb(cueSheetName).GetCueInfo(audioData.CueID, out CriAtomEx.CueInfo info)) { DebugUtil.Log("cue name: " + info.name); if (info.length <= 0) diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Bullet/ViewBullet.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Bullet/ViewBullet.cs index 94da5ae7cf2..0244f6fd9d4 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Bullet/ViewBullet.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Bullet/ViewBullet.cs @@ -145,7 +145,7 @@ namespace Gameplay.Bullet var audioId = configData.HitAudioId; if (audioId > 0) { - AudioManager.Instance.PlayAudio(audioId, AudioCriManager.EPlayType.Sound, rootObj).Forget(); + AudioManager.Instance.PlayAudioOld(audioId, AudioCriManager.EPlayType.Sound, rootObj).Forget(); } // 销毁obj if (rootObj != null) diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Character/Skill/CSA_PlayAudio.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Character/Skill/CSA_PlayAudio.cs index dc328bafc20..7b0b88ff782 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Character/Skill/CSA_PlayAudio.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Character/Skill/CSA_PlayAudio.cs @@ -8,7 +8,7 @@ namespace Gameplay.Character.Skill { // base._OnTrigger(); var owner = skill.GetOwner(); - AudioManager.Instance.PlayAudio(actionData.id, owner.transData.pos).Forget(); + AudioManager.Instance.PlayAudioOld(actionData.id, owner.transData.pos).Forget(); } diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Debug/SROptions.Audio.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Debug/SROptions.Audio.cs index eeb091853bc..448dc50d770 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Debug/SROptions.Audio.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Debug/SROptions.Audio.cs @@ -14,7 +14,7 @@ public partial class SROptions [DisplayName("播放音频")] public async void Play() { - int audioID = await AudioManager.Instance.PlayAudio(AudioID); + int audioID = await AudioManager.Instance.PlayAudioOld(AudioID); if (audioID < 0) { DebugUtil.LogError("Debug, Audio播放失败,请检查AudioID!"); diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Dialogue/DialogueManager.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Dialogue/DialogueManager.cs index 013e4987c57..3ae8cdbf347 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Dialogue/DialogueManager.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Dialogue/DialogueManager.cs @@ -66,7 +66,7 @@ public class DialogueManager : Singlenton, IInitable, IUpdatabl /// /// 当前播放的战斗台词 /// - private Audio curFightAudio; + private AudioInst curFightAudio; /// /// 当前战斗台词优先级 /// @@ -180,7 +180,7 @@ public class DialogueManager : Singlenton, IInitable, IUpdatabl /// /// /// - public async UniTask