public virtual void MuteSfx() { if (_overrided) { return; } AudioCollection audioCollection = FindObjectOfType <AudioCollection>(); if (audioCollection == null) { return; } IsSfxMuted = PlayerPrefs.GetInt("IsMuted") != 1; PlayerPrefs.SetInt("IsMuted", IsSfxMuted ? 1 : 0); GameObject audioManager = audioCollection.gameObject; AudioSource[] components = audioManager.GetComponents <AudioSource>(); foreach (var item in audioCollection.audioCollection.Where(audio => audio.Name.StartsWith("sfx"))) { foreach (var sfx in components.Where(i => i.clip.name.Equals(item.AudioClip.name))) { sfx.mute = IsSfxMuted; } } OnMuteGameEvent?.Invoke("sfx"); }
public virtual void MuteBackgroundMusic() { if (_overrided) { return; } AudioManager audioManager = FindObjectOfType <AudioManager>(); if (audioManager == null) { return; } IsBgMuted = PlayerPrefs.GetInt("IsBgMuted") != 1; PlayerPrefs.SetInt("IsBgMuted", IsBgMuted ? 1 : 0); audioManager.SetVolume("bg_game", IsBgMuted ? 0f : 0.3f); audioManager.SetVolume("bg_menu", IsBgMuted ? 0f : 0.3f); OnMuteGameEvent?.Invoke("bg"); }