Hi,
When an Unity Ad is showing in my game the audio (music) of the game can still be heard. This happens in the Unity editor when i’m in iOS build mode and the ads are in test mode (not sure if this will persist when the game is on app store).
Is their a way to properly disable the audio of the game right before showing the ad and activate it again after the ad?
I used AudioSource.Pause = true; but this will interupt the audio quite harsh. I tried an enumerator to give it a little delay, but this won’t work if I add this just in front of the ShowAd() method.
Any idea how to do this the correct way? This is my code for showing the add:
//Unity Ads Show When Ready
public void ShowAd ()
{
#if UNITY_EDITOR
StartCoroutine (WaitForAd());
#endif
if (Advertisement.IsReady ())
Advertisement.Show();
}
//Pauses the game to show ads
IEnumerator WaitForAd ()
{
float currentTimeScale = Time.timeScale;
Time.timeScale = 0f;
yield return null;
while (Advertisement.isShowing)
yield return null;
Time.timeScale = currentTimeScale;
}
public void ShowAdsNow (){
int number = Random.Range(1,6);
if (number == 4) {
ShowAd ();
}
}