I have a script that plays an ad every time you press the 'play again' or 'home' buttons. Code (CSharp): public void ShowAds() { if (Advertisement.IsReady("video")) { Advertisement.Show("video"); if (Advertisement.isShowing) { Time.timeScale = 0f; } } } This works perfectly fine, however I need to set my volume to 0 when the ad is playing and set it back to whatever it was if it isn't. I currently set my volume using a UI slider. Code (CSharp): using UnityEngine; using UnityEngine.Audio; using UnityEngine.UI; public class OptionsMenu : MonoBehaviour { public AudioMixer mixer; public Slider slider; public void SetVolume(float volume) { mixer.SetFloat("Volume", volume); } public void Start() { SetVolume(PlayerPrefs.GetFloat("Volume", 0)); slider.value = PlayerPrefs.GetFloat("Volume"); Time.timeScale = 1f; } public void OnDisable() { float Volume = 0f; mixer.GetFloat("Volume", out Volume); PlayerPrefs.SetFloat("Volume", Volume); PlayerPrefs.Save(); } } Please help!
Not sure what your question is. When you go play an ad, copy the current volume level, store it somewhere else, set it to zero, play the ad, and when you know the ad is done, restore the volume to both the slider and the mixer.
I don't understand how to do this, can you provide some code or an example(sorry i'm kind of new to unity).