AudioCore0.11
This commit is contained in:
@@ -8,7 +8,6 @@ public static class AudioCoreManager
|
||||
private static SFXPlayer SFX;
|
||||
private static MusicPlayer Music;
|
||||
|
||||
// 初始化 AudioCoreManager
|
||||
static AudioCoreManager()
|
||||
{
|
||||
audioSourcePool = new AudioSourcePool();
|
||||
@@ -18,39 +17,98 @@ public static class AudioCoreManager
|
||||
Music = new MusicPlayer(audioSourcePool);
|
||||
}
|
||||
|
||||
// 播放语音
|
||||
#region 语音
|
||||
|
||||
/// <summary>
|
||||
/// 播放语音
|
||||
/// </summary>
|
||||
/// <param name="clip">音频</param>
|
||||
/// <param name="onComplete">结束行为</param>
|
||||
/// <param name="delay">结束行为延迟执行时间</param>
|
||||
public static void PlayVoice(AudioClip clip, System.Action onComplete, float delay = 0f)
|
||||
{
|
||||
Voice.Play(clip, 1f, onComplete, delay);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放语音
|
||||
/// </summary>
|
||||
/// <param name="clip">音频</param>
|
||||
/// <param name="volume">音量</param>
|
||||
/// <param name="onComplete">结束行为</param>
|
||||
/// <param name="delay">结束行为延迟执行时间</param>
|
||||
public static void PlayVoice(AudioClip clip, float volume = 1f, System.Action onComplete = null, float delay = 0f)
|
||||
{
|
||||
Voice.Play(clip, volume, onComplete, delay);
|
||||
}
|
||||
|
||||
// 停止语音
|
||||
/// <summary>
|
||||
/// 停止当前的语音
|
||||
/// </summary>
|
||||
public static void StopVoice()
|
||||
{
|
||||
Voice.Stop();
|
||||
}
|
||||
|
||||
// 播放音效
|
||||
#endregion
|
||||
|
||||
#region 音效
|
||||
|
||||
/// <summary>
|
||||
/// 播放音效
|
||||
/// </summary>
|
||||
/// <param name="clip">音频</param>
|
||||
/// <param name="onComplete">结束行为</param>
|
||||
/// <param name="delay">结束行为延迟执行时间</param>
|
||||
public static void PlaySFX(AudioClip clip, System.Action onComplete, float delay = 0f)
|
||||
{
|
||||
SFX.Play(clip, 1f, onComplete, delay);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放音效
|
||||
/// </summary>
|
||||
/// <param name="clip">音频</param>
|
||||
/// <param name="volume">音量</param>
|
||||
/// <param name="onComplete">结束行为</param>
|
||||
/// <param name="delay">结束行为延迟执行时间</param>
|
||||
public static void PlaySFX(AudioClip clip, float volume = 1f, System.Action onComplete = null, float delay = 0f)
|
||||
{
|
||||
SFX.Play(clip, volume, onComplete, delay);
|
||||
}
|
||||
|
||||
// 停止所有音效
|
||||
/// <summary>
|
||||
/// 停止所有音效
|
||||
/// </summary>
|
||||
public static void StopAllSFX()
|
||||
{
|
||||
SFX.Stop();
|
||||
}
|
||||
|
||||
// 播放背景音乐
|
||||
public static void PlayMusic(AudioClip clip, float fadeDuration = 0f)
|
||||
#endregion
|
||||
|
||||
#region 背景音乐
|
||||
|
||||
/// <summary>
|
||||
/// 播放背景音乐
|
||||
/// </summary>
|
||||
/// <param name="clip">音频</param>
|
||||
/// <param name="volume">音量</param>
|
||||
/// <param name="fadeDuration">自然过渡时间</param>
|
||||
public static void PlayMusic(AudioClip clip, float volume = 1f, float fadeDuration = 1f)
|
||||
{
|
||||
Music.Play(clip, fadeDuration);
|
||||
Music.Play(clip, volume, fadeDuration);
|
||||
}
|
||||
|
||||
// 停止背景音乐
|
||||
/// <summary>
|
||||
/// 停止播放背景音乐
|
||||
/// </summary>
|
||||
/// <param name="fadeDuration">自然过渡时间</param>
|
||||
public static void StopMusic(float fadeDuration = 1f)
|
||||
{
|
||||
Music.Stop(fadeDuration);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user