public static void PlayAudioOneShot(AudioSource audioSource, int soundId, float volume = 1f) { if (_globalAudioVolume <= 0 || _audioVolume <= 0) { return; } SoundDeploy deploy = _soundTableT.GetSection(soundId); if (!deploy || string.IsNullOrEmpty(deploy.resource)) { return; } AudioClip resource; if (CachePool.TryGetValue(deploy.resource, out resource)) { PlayAudioOneShot(audioSource, resource, volume, deploy.volume); } else { RLoadPlayAudioOneShot(deploy.resource, audioSource, volume, deploy.volume); } }
public static void UnloadSoundAsset(AudioSource audioSource, int soundId) { if (audioSource != null) { SoundDeploy deploy = _soundTableT.GetSection(soundId); CachePool.Remove(deploy.resource); Resources.UnloadAsset(audioSource.clip); } }
public static void PlayEnvironmentMusic(int id, bool loop = true, float fade = 1f) { SoundDeploy deploy = _soundTableT.GetSection(id); if (!deploy) { return; } PlayEnvironmentMusic(deploy.resource, loop, deploy.volume, fade); }
public static void Load(int id, Action <SoundClip> notify) { SoundDeploy deploy = _soundTableT.GetSection(id); if (!deploy || string.IsNullOrEmpty(deploy.resource)) { return; } Load(deploy.resource, deploy.volume, notify); }
public static void PlayMusic(int id, bool loop = true, float fade = 1f, string tag = "") { SoundDeploy deploy = _soundTableT.GetSection(id); if (!deploy) { return; } PlayMusic(deploy.resource, tag, loop, deploy.volume, fade); }
private static void LoadPlayAudio(int id, AudioSource audioSource, bool loop, Action playCallBack) { if (!loop && (_globalAudioVolume <= 0 || _audioVolume <= 0)) { return; } SoundDeploy deploy = _soundTableT.GetSection(id); if (!deploy || string.IsNullOrEmpty(deploy.resource)) { return; } LoadPlayAudio(deploy.resource, audioSource, deploy.volume, loop, playCallBack); }