Files
zeling_v2/Assets/Scripts/Core/NullAudioService.cs
2026-05-12 15:34:08 +08:00

28 lines
1.2 KiB
C#

using UnityEngine;
namespace BaseGames.Core
{
/// <summary>
/// IAudioService 的空实现,作为兜底防止 NullReferenceException。
/// 在 GameServiceRegistrar 中作为默认音频服务注册;
/// AudioManager 初始化后会覆盖此实现。
/// </summary>
public sealed class NullAudioService : IAudioService
{
public void PlayBGM(string key)
=> Debug.LogWarning($"[NullAudioService] PlayBGM({key}) — 音频系统未初始化。");
public void StopBGM(float fadeTime = 0f)
=> Debug.LogWarning("[NullAudioService] StopBGM — 音频系统未初始化。");
public void PlaySFX(string key)
=> Debug.LogWarning($"[NullAudioService] PlaySFX({key}) — 音频系统未初始化。");
public void PlaySFXAtPosition(AudioClip clip, Vector2 position, float volumeScale = 1f)
=> Debug.LogWarning($"[NullAudioService] PlaySFXAtPosition({clip?.name}) — 音频系统未初始化。");
public void SetVolume(string group, float normalizedVolume)
=> Debug.LogWarning($"[NullAudioService] SetVolume({group}, {normalizedVolume}) — 音频系统未初始化。");
}
}