Quantcast
Channel: Questions in topic: "ads"
Viewing all articles
Browse latest Browse all 1416

How to freeze the game when playing an ad?

$
0
0
Im trying to make my game so that after every 5 times the person plays, it shows an ad. However whenevr I show an ad, the game continues in the background. I made it so that it freezes time, and resumes when the ad is skipped, finished or failed, but it doesnt work. Is that a problem in the script or a problem because it isnt a real ad? using UnityEngine; using UnityEngine.Advertisements; public class UnityAds : MonoBehaviour { public void ShowAd() { int newNum = PlayerPrefs.GetInt ("count"); if (Advertisement.IsReady()) { if(PlayerPrefs.GetInt("count") > 5){ Time.timeScale = 0; Advertisement.Show(); PlayerPrefs.SetInt("count", 0); } else{ PlayerPrefs.SetInt("count", newNum+5); } } } private void HandleShowResult(ShowResult result){ switch (result) { case ShowResult.Finished: Time.timeScale = 1; break; case ShowResult.Skipped: Time.timeScale = 1; break; case ShowResult.Failed: Time.timeScale = 1; break; } } }

Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>