AudioCore0.1
This commit is contained in:
56
Assets/04.AudioCore/RunTime/AudioCoreManager.cs
Normal file
56
Assets/04.AudioCore/RunTime/AudioCoreManager.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static class AudioCoreManager
|
||||
{
|
||||
private static AudioSourcePool audioSourcePool;
|
||||
private static VoicePlayer Voice;
|
||||
private static SFXPlayer SFX;
|
||||
private static MusicPlayer Music;
|
||||
|
||||
// 初始化 AudioCoreManager
|
||||
static AudioCoreManager()
|
||||
{
|
||||
audioSourcePool = new AudioSourcePool();
|
||||
// 初始化播放器
|
||||
Voice = new VoicePlayer(audioSourcePool);
|
||||
SFX = new SFXPlayer(audioSourcePool);
|
||||
Music = new MusicPlayer(audioSourcePool);
|
||||
}
|
||||
|
||||
// 播放语音
|
||||
public static void PlayVoice(AudioClip clip, float volume = 1f, System.Action onComplete = null, float delay = 0f)
|
||||
{
|
||||
Voice.Play(clip, volume, onComplete, delay);
|
||||
}
|
||||
|
||||
// 停止语音
|
||||
public static void StopVoice()
|
||||
{
|
||||
Voice.Stop();
|
||||
}
|
||||
|
||||
// 播放音效
|
||||
public static void PlaySFX(AudioClip clip, float volume = 1f, System.Action onComplete = null, float delay = 0f)
|
||||
{
|
||||
SFX.Play(clip, volume, onComplete, delay);
|
||||
}
|
||||
|
||||
// 停止所有音效
|
||||
public static void StopAllSFX()
|
||||
{
|
||||
SFX.Stop();
|
||||
}
|
||||
|
||||
// 播放背景音乐
|
||||
public static void PlayMusic(AudioClip clip, float fadeDuration = 0f)
|
||||
{
|
||||
Music.Play(clip, fadeDuration);
|
||||
}
|
||||
|
||||
// 停止背景音乐
|
||||
public static void StopMusic(float fadeDuration = 1f)
|
||||
{
|
||||
Music.Stop(fadeDuration);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user