【音频】音频修改为流式播放
parent
4f37e94a3b
commit
0f3df6f312
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -8,10 +8,13 @@ using AudioType = PhxhSDK.AudioBase.AudioType;
|
|||
|
||||
public class AudioCriManager: Singlenton<AudioCriManager>, 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<AudioCriManager>, 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取音频输出分析器配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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<AudioCriManager>, 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<CriWareErrorHandler>();
|
||||
Object.DontDestroyOnLoad(_criError);
|
||||
}
|
||||
|
||||
|
||||
CriAtomRoot = GameObject.Find("CriAtom");
|
||||
CriAtom = CriAtomRoot.GetComponent<CriAtom>();
|
||||
Object.DontDestroyOnLoad(CriAtomRoot);
|
||||
|
||||
|
||||
_soundAudioDic = new Dictionary<int, AudioInst>();
|
||||
_musicAudioDic = new Dictionary<int, AudioInst>();
|
||||
_allAudioDic = new Dictionary<int, AudioInst>();
|
||||
|
||||
// CriAtomRoot = new GameObject()
|
||||
}
|
||||
// CriAtomRoot = new GameObject()
|
||||
// {
|
||||
// name = "CriAtom"
|
||||
// };
|
||||
|
|
@ -93,12 +156,15 @@ public class AudioCriManager: Singlenton<AudioCriManager>, IStart, IInitable, IU
|
|||
// };
|
||||
// go.transform.SetParent(AudioRoot.transform);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
||||
_soundAudioDic = new Dictionary<int, AudioInst>();
|
||||
_musicAudioDic = new Dictionary<int, AudioInst>();
|
||||
_allAudioDic = new Dictionary<int, AudioInst>();
|
||||
_soundAudioObj = new();
|
||||
_musicAudioObj = new();
|
||||
}
|
||||
|
||||
public void Release()
|
||||
|
|
@ -131,9 +197,66 @@ public class AudioCriManager: Singlenton<AudioCriManager>, 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<AudioCriManager>, 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<AudioCriManager>, 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<AudioCriManager>, IStart, IInitable, IU
|
|||
|
||||
#region Play
|
||||
|
||||
/// <summary>
|
||||
/// 调用接口,传obj
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="posObj"></param>
|
||||
/// <returns></returns>
|
||||
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<AudioCriManager>, IStart, IInitable, IU
|
|||
{
|
||||
return _PlaySound(key, path, posObj);
|
||||
}
|
||||
case EPlayType.Speak:
|
||||
{
|
||||
return _PlaySpeakSound(key, path, posObj);
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调用接口,传位置
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
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<AudioCriManager>, 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<AudioCriManager>, 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<AudioCriManager>, 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<AudioCriManager>, 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<CriAtomListener>();
|
||||
if (!listener)
|
||||
{
|
||||
camera.gameObject.AddComponent<CriAtomListener>();
|
||||
}
|
||||
}
|
||||
|
||||
public CriAtomExAcb GetAcb(string cueSheetName)
|
||||
{
|
||||
return CriAtom.GetAcb(cueSheetName);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public class AudioInst : AudioCri
|
||||
|
|
|
|||
|
|
@ -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<CriWareErrorHandler>();
|
||||
Object.DontDestroyOnLoad(_criError);
|
||||
}
|
||||
// if (curClipType == ClipType.CriwareClip)
|
||||
// {
|
||||
// _criError = new GameObject();
|
||||
// _criError.name = "CriwareError";
|
||||
// _criError.AddComponent<CriWareErrorHandler>();
|
||||
// Object.DontDestroyOnLoad(_criError);
|
||||
// }
|
||||
|
||||
_rootGoList = new List<GameObject>();
|
||||
_audioDic = new Dictionary<GameObject, Audio>();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ using UnityEngine;
|
|||
|
||||
public class AudioManager: Singlenton<AudioManager>, 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<AudioManager>, 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<AudioManager>, 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<AudioManager>, IStart, IInitable, IUpdatab
|
|||
{
|
||||
GlobalSoundsVolume = isEnable ? 1 : 0;
|
||||
}
|
||||
public async UniTask<int> 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<int> 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<int> 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<int> 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<int> PlayAudio(string key, Vector3 pos, AudioCriManager.EPlayType type = AudioCriManager.EPlayType.Sound)
|
||||
public async UniTask<int> 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<int> 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<int> 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<AudioManager>, 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);
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ public class AlbumManager : Singlenton<AlbumManager>
|
|||
{
|
||||
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<AlbumManager>
|
|||
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<AlbumManager>
|
|||
{
|
||||
//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<AlbumManager>
|
|||
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<AlbumManager>
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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!");
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class DialogueManager : Singlenton<DialogueManager>, IInitable, IUpdatabl
|
|||
/// <summary>
|
||||
/// 当前播放的战斗台词
|
||||
/// </summary>
|
||||
private Audio curFightAudio;
|
||||
private AudioInst curFightAudio;
|
||||
/// <summary>
|
||||
/// 当前战斗台词优先级
|
||||
/// </summary>
|
||||
|
|
@ -180,7 +180,7 @@ public class DialogueManager : Singlenton<DialogueManager>, IInitable, IUpdatabl
|
|||
/// <param name="dialogueType"></param>
|
||||
/// <param name="callback"></param>
|
||||
/// <returns></returns>
|
||||
public async UniTask<Audio> PlayDiaogue(int roleId, E_DialogueType dialogueType, Action<string> callback = null)
|
||||
public async UniTask<AudioInst> PlayDiaogue(int roleId, E_DialogueType dialogueType, Action<string> callback = null)
|
||||
{
|
||||
if (!isInit)
|
||||
{
|
||||
|
|
@ -277,11 +277,11 @@ public class DialogueManager : Singlenton<DialogueManager>, IInitable, IUpdatabl
|
|||
int realId = roleId * RATIO + playCfg.Id;
|
||||
string audioKey = GetAudioKey(roleId, playCfg.Id);
|
||||
DebugUtil.Log($"角色id:{roleId}, 播放台词id:{playCfg.Id}, 优先级{playCfg.Priority},音频key:{audioKey}"); // 测试Log
|
||||
int audioId = await AudioManager.Instance.PlayAudio(GetAudioKey(roleId, playCfg.Id));
|
||||
|
||||
//int audioId = await AudioManager.Instance.PlayAudio(GetAudioKey(roleId, playCfg.Id));
|
||||
int audioId = AudioManager.Instance.PlayAudio(GetAudioKey(roleId, playCfg.Id));
|
||||
callback?.Invoke(CommonUtils.GetLocalizeText(E_LocalizePrefix.Dialogue, realId));
|
||||
|
||||
return AudioManager.Instance.GetAudioByID(AudioType.SOUND, audioId);
|
||||
return AudioManager.Instance.GetAudioByID(AudioCriManager.EPlayType.Speak, audioId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -344,10 +344,11 @@ public class DialogueManager : Singlenton<DialogueManager>, IInitable, IUpdatabl
|
|||
|
||||
string audioKey = GetAudioKey(roleId, cfg.Id);
|
||||
DebugUtil.Log($"角色id:{roleId}, 播放台词id:{cfg.Id}, 优先级{cfg.Priority},实际音频key:{audioKey},概率:{cfg.TriggerProbability * 100}%"); // 测试Log
|
||||
int audioId = await AudioManager.Instance.PlayAudio(audioKey);
|
||||
//int audioId = await AudioManager.Instance.PlayAudio(audioKey);
|
||||
int audioId = AudioManager.Instance.PlayAudio(audioKey);
|
||||
curFightDialoguePriority = cfg.Priority;
|
||||
curFightDialogueType = dialogueType;
|
||||
curFightAudio = AudioManager.Instance.GetAudioByID(AudioType.SOUND, audioId);
|
||||
curFightAudio = AudioManager.Instance.GetAudioByID(AudioCriManager.EPlayType.Speak, audioId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -259,7 +259,8 @@ namespace Gameplay.Level
|
|||
|
||||
public async void PlayBGM()
|
||||
{
|
||||
_bgmID = await AudioManager.Instance.PlayAudio("NLD_BGM_01");
|
||||
//_bgmID = await AudioManager.Instance.PlayAudio("NLD_BGM_01");
|
||||
_bgmID = AudioManager.Instance.PlayAudio("bgm_01");
|
||||
}
|
||||
|
||||
public void StopBGM()
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ namespace Gameplay.Summon
|
|||
// 播放销毁音效
|
||||
if (configData.DestroyAudioId > 0)
|
||||
{
|
||||
AudioManager.Instance.PlayAudio(configData.DestroyAudioId, AudioCriManager.EPlayType.Sound, Node.GameObject).Forget();
|
||||
AudioManager.Instance.PlayAudioOld(configData.DestroyAudioId, AudioCriManager.EPlayType.Sound, Node.GameObject).Forget();
|
||||
}
|
||||
base.OnDispose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class UI_DrawPannelCharacterController : UIWindow
|
|||
/// <summary>
|
||||
/// 台词语音
|
||||
/// </summary>
|
||||
private Audio dialogueAudio;
|
||||
private AudioInst dialogueAudio;
|
||||
/// <summary>
|
||||
/// 抽卡数据
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class UI_RaffleOneResultController : UIWindow
|
|||
/// <summary>
|
||||
/// 台词语音
|
||||
/// </summary>
|
||||
private Audio dialogueAudio;
|
||||
private AudioInst dialogueAudio;
|
||||
private DrawData raffleData;
|
||||
|
||||
public override void OnInit()
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ public class UIAdvanceController : UIWindow
|
|||
/// <summary>
|
||||
/// 台词语音
|
||||
/// </summary>
|
||||
private Audio dialogueAudio;
|
||||
private AudioInst dialogueAudio;
|
||||
/// <summary>
|
||||
/// 台词UI
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ public class UILevelUpController : UIWindow
|
|||
|
||||
public DragForUI dragForUI;
|
||||
|
||||
private Audio dialogueAudio;
|
||||
private AudioInst dialogueAudio;
|
||||
private Dialogue dialogue;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1054,7 +1054,7 @@ public class UI_MainPanelController : UIWindow
|
|||
/// 音频输出分析器
|
||||
/// </summary>
|
||||
private CriAtomExOutputAnalyzer analyzer;
|
||||
private Audio dialogueAudio;
|
||||
private AudioInst dialogueAudio;
|
||||
/// <summary>
|
||||
/// 货币栏
|
||||
/// </summary>
|
||||
|
|
@ -1158,7 +1158,7 @@ public class UI_MainPanelController : UIWindow
|
|||
CommonUtils.BindButton(buttonMission, OnTask);
|
||||
CommonUtils.BindButton(buttonMusic, OnMusic);
|
||||
|
||||
analyzer = AudioManager.Instance.RegisterAnalyzer();//获取AudioCriwareManager内的analyzer
|
||||
//analyzer = AudioManager.Instance.RegisterAnalyzer();//获取AudioCriwareManager内的analyzer
|
||||
EventManager.Instance.Register(EventManager.EventName.UIOpen, OnStopDiaogue);
|
||||
EventManager.Instance.Register(EventManager.EventName.ChangeMainPanelPoster, RefreshPoster);
|
||||
EventManager.Instance.Register<uint>(EventManager.EventName.ItemChange, OnItemChange);
|
||||
|
|
@ -1323,7 +1323,8 @@ public class UI_MainPanelController : UIWindow
|
|||
return;
|
||||
|
||||
//await AudioManager.Instance.PlayAudio("NLD_BGM_09999");
|
||||
await AudioManager.Instance.PlayAudio("NLD_BGM_02");
|
||||
//await AudioManager.Instance.PlayAudio("NLD_BGM_02");
|
||||
AudioManager.Instance.PlayAudio("bgm_02", AudioCriManager.EPlayType.Music);
|
||||
if (AlbumManager.Instance.GetCurThemeAlbum() != 0)//设置主题专辑
|
||||
{
|
||||
AudioManager.Instance.IsPlayingAlbum = true;
|
||||
|
|
@ -1452,8 +1453,8 @@ public class UI_MainPanelController : UIWindow
|
|||
/// </summary>
|
||||
private void RefreshMusicDance()
|
||||
{
|
||||
analyzer?.GetSpectrumLevels(ref spectrums);
|
||||
musicDance.SetInfo(spectrums);
|
||||
//analyzer?.GetSpectrumLevels(ref spectrums);
|
||||
//musicDance.SetInfo(spectrums);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
PhxhScrollView AudioListScrollView;
|
||||
|
||||
/// <summary>
|
||||
/// 频谱分析数组
|
||||
/// 频谱分析数组
|
||||
/// </summary>
|
||||
private float[] spectrums;
|
||||
MusicDance musicDance;
|
||||
|
|
@ -156,7 +156,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
|
||||
BindButton(Button_back, _OnClickClose);
|
||||
|
||||
if (AlbumManager.Instance.GetCurThemeAlbum() == 0)//未设置主题专辑在播放默认bgm
|
||||
if (AlbumManager.Instance.GetCurThemeAlbum() == 0)//未设置主题专辑在播放默认bgm
|
||||
{
|
||||
DebugUtil.Log("pause music");
|
||||
AudioManager.Instance.PauseBackgroundMusic();
|
||||
|
|
@ -204,12 +204,12 @@ public class UI_MusicPannelController : UIWindow
|
|||
PauseAndResume();
|
||||
//if (!isPlaying)
|
||||
//{
|
||||
PauseAndResume();//用于加载音频
|
||||
PauseAndResume();//用于加载音频
|
||||
//}
|
||||
curAudioLength = AlbumManager.Instance.GetAlbumLength(AlbumManager.Instance.curMusicKey);
|
||||
|
||||
float totalSeconds = AlbumManager.Instance.GetAlbumProgress();
|
||||
DebugUtil.Log(AlbumManager.Instance.curMusicKey + "当前已播放时长:" + totalSeconds);
|
||||
DebugUtil.Log(AlbumManager.Instance.curMusicKey + "当前已播放时长:" + totalSeconds);
|
||||
int minutes = Mathf.FloorToInt(totalSeconds / 60F);
|
||||
int seconds = Mathf.FloorToInt(totalSeconds - minutes * 60);
|
||||
Text_TimeNow.text = $"{minutes:00}:{seconds:00}";
|
||||
|
|
@ -240,15 +240,16 @@ public class UI_MusicPannelController : UIWindow
|
|||
public override void OnRelease()
|
||||
{
|
||||
base.OnRelease();
|
||||
if (AlbumManager.Instance.GetCurThemeAlbum() == 0)//未设置主题专辑
|
||||
if (AlbumManager.Instance.GetCurThemeAlbum() == 0)//未设置主题专辑
|
||||
{
|
||||
DebugUtil.Log("resume music");
|
||||
if (AudioManager.Instance.IsPlayingAlbum)
|
||||
PauseAndResume();
|
||||
AudioManager.Instance.ResumeBackgroundMusic();
|
||||
AudioManager.Instance.PlayAudio("NLD_BGM_02").Forget();
|
||||
//AudioManager.Instance.PlayAudio("NLD_BGM_02").Forget();
|
||||
AudioManager.Instance.PlayAudio("bgm_02", AudioCriManager.EPlayType.Music);
|
||||
}
|
||||
else if (AlbumManager.Instance.GetCurThemeAlbum() != AlbumManager.Instance.GetCurAlbum().Id)//设置主题专辑但与当前播放不一致
|
||||
else if (AlbumManager.Instance.GetCurThemeAlbum() != AlbumManager.Instance.GetCurAlbum().Id)//设置主题专辑但与当前播放不一致
|
||||
{
|
||||
AlbumManager.Instance.SetCurAlbum(AlbumManager.Instance.GetCurThemeAlbum(), AlbumManager.Instance.GetCurThemeAudioIndex());
|
||||
int curAlbumIndex = AlbumManager.Instance.GetCurThemeAlbum();
|
||||
|
|
@ -313,7 +314,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
AudioManager.Instance.IsPlayingAlbum = !AudioManager.Instance.IsPlayingAlbum;
|
||||
if (AudioManager.Instance.IsPlayingAlbum)
|
||||
{
|
||||
if (!AlbumManager.Instance.PauseAndResumeAlbum(false))//未播放
|
||||
if (!AlbumManager.Instance.PauseAndResumeAlbum(false))//未播放
|
||||
{
|
||||
//await AudioManager.Instance.PlayAlbum(dataAudio.ID);
|
||||
//AlbumManager.Instance.curMusicKey = dataAudio.Key;
|
||||
|
|
@ -326,7 +327,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
int seconds = Mathf.FloorToInt(curAudioLength - minutes * 60);
|
||||
Text_AllTime.text = $"{minutes:00}:{seconds:00}";
|
||||
}
|
||||
//else//从暂停中恢复
|
||||
//else//从暂停中恢复
|
||||
//{
|
||||
// albumTimer.Start(Text_TimeNow);
|
||||
//}
|
||||
|
|
@ -350,7 +351,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
AlbumManager.Instance.PauseAndResumeAlbum(false);
|
||||
|
||||
AlbumManager.Instance.PlayAlbumAudio(curAlbumIndex, index);
|
||||
AlbumManager.Instance.SetPlayList();//SetPlayMode(AlbumManager.Instance.CurPlayMode);//TODO 播放模式
|
||||
AlbumManager.Instance.SetPlayList();//SetPlayMode(AlbumManager.Instance.CurPlayMode);//TODO 播放模式
|
||||
|
||||
DataAudio dataAudio = TableManager.Instance.Tables.Audios.GetByID(AlbumManager.Instance.AlbumPlayList(curAlbumIndex)[index]);
|
||||
|
||||
|
|
@ -373,7 +374,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
{
|
||||
if (CategoryManager.Instance.GetItemCount(cost[0].Id) < cost[0].Count)
|
||||
{
|
||||
DebugUtil.LogError("货币不足!");
|
||||
DebugUtil.LogError("货币不足!");
|
||||
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("shop_noMoney"));
|
||||
return;
|
||||
}
|
||||
|
|
@ -384,13 +385,13 @@ public class UI_MusicPannelController : UIWindow
|
|||
}
|
||||
else
|
||||
{
|
||||
DebugUtil.LogError("未配置解锁消耗道具!");
|
||||
DebugUtil.LogError("未配置解锁消耗道具!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
void OnSetThemeAlbumClick()
|
||||
{
|
||||
DebugUtil.Log("当前专辑ID:" + curAlbumIndex);
|
||||
DebugUtil.Log("当前专辑ID:" + curAlbumIndex);
|
||||
if (curAlbumIndex != AlbumManager.Instance.GetCurThemeAlbum())
|
||||
{
|
||||
AlbumManager.Instance.SetCurThemeAlbum(curAlbumIndex);
|
||||
|
|
@ -443,7 +444,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
var audioID = audioLst[index];
|
||||
DataAudio audioCfg = TableManager.Instance.Tables.Audios.GetByID(audioID);//.GetConfigData(audioID);
|
||||
|
||||
if (curAlbumIndex == AlbumManager.Instance.GetCurAlbum().Id && index == AlbumManager.Instance.GetCurAudioIndex())//当前播放
|
||||
if (curAlbumIndex == AlbumManager.Instance.GetCurAlbum().Id && index == AlbumManager.Instance.GetCurAudioIndex())//当前播放
|
||||
{
|
||||
rt.Find("Image_NotChoose").gameObject.SetActive(false);
|
||||
rt.Find("Image_ChooseBar").gameObject.SetActive(true);
|
||||
|
|
@ -464,7 +465,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
ClearBind(rt.Find("Image_ChooseBar").GetComponent<Button>());
|
||||
BindButton(rt.Find("Image_ChooseBar").GetComponent<Button>(), PauseAndResume);
|
||||
}
|
||||
else//未播放
|
||||
else//未播放
|
||||
{
|
||||
rt.Find("Image_NotChoose").gameObject.SetActive(true);
|
||||
rt.Find("Image_ChooseBar").gameObject.SetActive(false);
|
||||
|
|
@ -559,12 +560,12 @@ public class UI_MusicPannelController : UIWindow
|
|||
}
|
||||
else
|
||||
{
|
||||
DebugUtil.LogError("错误的解锁消耗类型!");
|
||||
DebugUtil.LogError("错误的解锁消耗类型!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtil.LogError("未配置解锁消耗道具!");
|
||||
DebugUtil.LogError("未配置解锁消耗道具!");
|
||||
|
||||
Text_SpendLocalText.gameObject.SetActive(false);
|
||||
Button_UnLock.gameObject.SetActive(false);
|
||||
|
|
@ -591,7 +592,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
|
||||
}
|
||||
/// <summary>
|
||||
/// 计时器更新回调
|
||||
/// 计时器更新回调
|
||||
/// </summary>
|
||||
void TimerRefresh()
|
||||
{
|
||||
|
|
@ -607,7 +608,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
musicDance.SetInfo(spectrums);
|
||||
}
|
||||
/// <summary>
|
||||
/// 当音乐播放结束或切歌时刷新显示当前播放歌曲
|
||||
/// 当音乐播放结束或切歌时刷新显示当前播放歌曲
|
||||
/// </summary>
|
||||
void PlayEndRefresh()
|
||||
{
|
||||
|
|
@ -626,7 +627,7 @@ public class UI_MusicPannelController : UIWindow
|
|||
}
|
||||
|
||||
///// <summary>
|
||||
///// 播放进度计时器
|
||||
///// 播放进度计时器
|
||||
///// </summary>
|
||||
//class Timer
|
||||
//{
|
||||
|
|
|
|||
|
|
@ -666,11 +666,6 @@ namespace Gameplay.Unit
|
|||
_OnUseSkill(cellIndex, skillHandle);
|
||||
}
|
||||
|
||||
private async void PlayAudio()
|
||||
{
|
||||
await AudioManager.Instance.PlayAudio("DemoProj_S1");
|
||||
}
|
||||
|
||||
protected virtual void _OnUseSkill(int cellIndex,
|
||||
SkillHandle skillHandle)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ namespace Gameplay.Vehicle
|
|||
var fireAudioIds = weaponConfig.FireAudioId;
|
||||
if (fireAudioIds.Count <= 0) return;
|
||||
var fireAudioId = fireAudioIds[Random.Range(0, fireAudioIds.Count)];
|
||||
AudioManager.Instance.PlayAudio(fireAudioId, owner.fireTrans.position).Forget();
|
||||
AudioManager.Instance.PlayAudioOld(fireAudioId, owner.fireTrans.position).Forget();
|
||||
}
|
||||
|
||||
private void _ShowFireEffects(GameUnit targetEnemy)
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ namespace Gameplay.Weapon
|
|||
if (rawConfig.FireAudioId.Count > 0)
|
||||
{
|
||||
var fireAudioId = rawConfig.FireAudioId[Random.Range(0, rawConfig.FireAudioId.Count)];
|
||||
AudioManager.Instance.PlayAudio(fireAudioId, fireTrans.position).Forget();
|
||||
AudioManager.Instance.PlayAudioOld(fireAudioId, fireTrans.position).Forget();
|
||||
}
|
||||
|
||||
var fireEffectId = rawConfig.FireEffectId;
|
||||
|
|
|
|||
|
|
@ -906,11 +906,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
acfFile: CueSheet_VOICE.acf
|
||||
cueSheets:
|
||||
- name: Voice_100001_01
|
||||
acbFile: CueSheet_VOICE.acb
|
||||
awbFile: CueSheet_VOICE.awb
|
||||
loaderStatus: 0
|
||||
cueSheets: []
|
||||
dspBusSetting:
|
||||
dontDestroyOnLoad: 0
|
||||
dontRemoveExistsCueSheet: 0
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -0,0 +1,22 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 29b001f710cc4a947b0d619de5b53798
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: d286586ba24ad438aac133d47a3e12b0, type: 3}
|
||||
implementation:
|
||||
rid: 1207811832167792640
|
||||
awb: {instanceID: 0}
|
||||
assetInfo:
|
||||
awb: {fileID: -6750239444755058063, guid: 457c267486916ea4392d6e204aa934be, type: 3}
|
||||
decryptionKeyForEditor: 0
|
||||
references:
|
||||
version: 2
|
||||
RefIds:
|
||||
- rid: 1207811832167792640
|
||||
type: {class: CriStreamingFolderAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor}
|
||||
data:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,18 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ad143a81c3a7c7343bb06a9ac66452f2
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 7cb389209abe442de834ce7a701e2513, type: 3}
|
||||
implementation:
|
||||
rid: 1000
|
||||
references:
|
||||
version: 2
|
||||
RefIds:
|
||||
- rid: 1000
|
||||
type: {class: CriStreamingFolderAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor}
|
||||
data:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,18 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5e01a4126c4df304093440b8676b40b1
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 503c02039ceed4218bb78fdac1d6a536, type: 3}
|
||||
implementation:
|
||||
rid: 1000
|
||||
references:
|
||||
version: 2
|
||||
RefIds:
|
||||
- rid: 1000
|
||||
type: {class: CriStreamingFolderAssetImplCreator, ns: CriWare.Assets, asm: CriMw.CriWare.Assets.Editor}
|
||||
data:
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5671919948717f84d9edef07d5f0f8e4
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -1,7 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9c844340fb9b0bd4a991a3daa10a0e52
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue