I was wondering how i can pause my game while the ads are showing
Your game should automatically be paused while the video ad is shown. Please provide some information about which version of SDK you are using, and if possible some code that shows how you show the ad.
/Rasmus
You can just stop executing your game logic, or depending on how you have things set up, adjust Time.timescale
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
public class RestartGameScript : MonoBehaviour {
public GameObject restartButton;
void Start()
{
Advertisement.Initialize ("42968", true);
StartCoroutine (ShowAdWhenReady());
}
IEnumerator ShowAdWhenReady ()
{
while (!Advertisement.isReady())
yield return null;
Advertisement.Show ();
}
public void RestartGame () {
{
Application.LoadLevel (Application.loadedLevel);
}
}
}
I used this so i can have the ad show when it restarts, also I believe i have version 1.1.4.
When running your app on device, the Unity Player will pause while Unity Ads are shown. However, if you are testing in the Unity Editor, the game is not paused while the placeholder ads are shown.
You could handle this by pausing audio playback and setting the timescale to 0 while showing. Then un-pause the audio and restore the timescale value after the ad placeholder is closed.
There used to be pausing functionality in the Unity Editor. This was removed when we removed support for picture ads.
Wish I had read this 30 minutes ago. I eventually learned by trial and error, even though I’m not supposed to disable test-mode. Sorry :S
OK, I lost 2 hours of my life trying to debug why the game wasn’t pausing even when I was forcing it to pause setting timescale to 0.
Good to know.
Would be nice to add this to the docs tho.
Thanks.