116 lines
2.8 KiB
C#
116 lines
2.8 KiB
C#
using System;
|
|
using CriWare;
|
|
using CriWare.Assets;
|
|
using Cysharp.Threading.Tasks;
|
|
using PhxhSDK;
|
|
using UnityEngine;
|
|
|
|
public class AudioManager: Singlenton<AudioManager>, IStart, IInitable, IUpdatable, IAudioPlay
|
|
{
|
|
private AudioCriwareManager _audioMgrObj = new();
|
|
|
|
public GameObject initGameObject;
|
|
|
|
public AudioCriwareManager AudioMgrObj
|
|
{
|
|
get { return _audioMgrObj; }
|
|
}
|
|
|
|
private void AfterSwitchCamera(bool isRegister = true)
|
|
{
|
|
if (isRegister)
|
|
{
|
|
CameraManager.Instance.AfterSwitchMainCamera += _audioMgrObj.AfterSwitchMainCamera;
|
|
}
|
|
else
|
|
{
|
|
CameraManager.Instance.AfterSwitchMainCamera -= _audioMgrObj.AfterSwitchMainCamera;
|
|
}
|
|
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
_audioMgrObj.Init();
|
|
AfterSwitchCamera();
|
|
}
|
|
|
|
public void Release()
|
|
{
|
|
_audioMgrObj.Release();
|
|
AfterSwitchCamera(false);
|
|
}
|
|
|
|
public void Start()
|
|
{
|
|
_audioMgrObj.Start();
|
|
initGameObject = _audioMgrObj.initGameObject;
|
|
}
|
|
|
|
public void Update(float dt)
|
|
{
|
|
_audioMgrObj.Update(dt);
|
|
}
|
|
public float GlobalVolume
|
|
{
|
|
get { return _audioMgrObj.GlobalVolume; }
|
|
set { _audioMgrObj.GlobalVolume = value; }
|
|
}
|
|
|
|
public float GlobalMusicVolume
|
|
{
|
|
get { return _audioMgrObj.GlobalMusicVolume; }
|
|
set { _audioMgrObj.GlobalMusicVolume = value; }
|
|
}
|
|
|
|
public float GlobalSoundsVolume
|
|
{
|
|
get { return _audioMgrObj.GlobalSoundsVolume; }
|
|
set { _audioMgrObj.GlobalSoundsVolume = value; }
|
|
}
|
|
|
|
public bool GlobalIsSpeakOpen
|
|
{
|
|
get { return _audioMgrObj.GlobalIsOpenSpeak; }
|
|
set { _audioMgrObj.GlobalIsOpenSpeak = value; }
|
|
}
|
|
|
|
public void SetMusicEnable(bool isEnable)
|
|
{
|
|
GlobalMusicVolume = isEnable ? 1 : 0;
|
|
}
|
|
|
|
public void SetSoundEnable(bool isEnable)
|
|
{
|
|
GlobalSoundsVolume = isEnable ? 1 : 0;
|
|
}
|
|
public async UniTask<int> PlayAudio(string key, Transform trans = null)
|
|
{
|
|
return await _audioMgrObj.PlayAudio(key, trans);
|
|
}
|
|
|
|
public async UniTask<int> PlayAudio(string key, Vector3 pos)
|
|
{
|
|
return await _audioMgrObj.PlayAudio(key, pos);
|
|
}
|
|
|
|
public async UniTask<int> PlayAudio(int id, Transform trans = null)
|
|
{
|
|
return await _audioMgrObj.PlayAudio(id, trans);
|
|
}
|
|
|
|
public async UniTask<int> PlayAudio(int id, Vector3 pos)
|
|
{
|
|
return await _audioMgrObj.PlayAudio(id, pos);
|
|
}
|
|
|
|
public void RegisterAnalyzer(CriAtomExOutputAnalyzer criAtomExOutputAnalyzer)
|
|
{
|
|
_audioMgrObj.RegisterAnalyzer(criAtomExOutputAnalyzer);
|
|
}
|
|
|
|
public void UnregisterAnalyzer(CriAtomExOutputAnalyzer criAtomExOutputAnalyzer)
|
|
{
|
|
_audioMgrObj.UnregisterAnalyzer(criAtomExOutputAnalyzer);
|
|
}
|
|
} |