- Home /
unity ads only shows up to 8 ads in a row in my app
Hello, I have a problem with unity ads in my game. In my game I have a button that when clicked shows an ad and gives the user coins. For some reason the ads only work between 6-8 times in a row. And only begin to work again a few hours later. Here is the code for the button:
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
public class WatchUnityAd : MonoBehaviour
{
public int numOfCoinsToAdd = 5;
bool paused = false,CRRuning = false;
// Use this for initialization
void Start()
{
//Advertisement.Initialize("66223",false);
}
public void ShowAd(string zone = "")
{
#if UNITY_EDITOR
StartCoroutine(WaitForAd());
#endif
if (string.Equals(zone, ""))
zone = null;
/*while (!Advertisement.isInitialized)
{
Advertisement.Initialize("66223", false);
}*/
ShowOptions options = new ShowOptions();
options.resultCallback = AdCallbackhandler;
if (Advertisement.IsReady())
Advertisement.Show(zone, options);
}
void AdCallbackhandler(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("Ad Finished. Rewarding player...");
int coinTotal = PlayerPrefs.GetInt("coinTotal");
coinTotal += numOfCoinsToAdd;
PlayerPrefs.SetInt("coinTotal", coinTotal);
gameObject.SetActive(false);
break;
case ShowResult.Skipped:
Debug.Log("Ad skipped. Son, I am dissapointed in you");
break;
case ShowResult.Failed:
Debug.Log("I swear this has never happened to me before");
break;
}
}
IEnumerator WaitForAd()
{
float currentTimeScale = Time.timeScale;
Time.timeScale = 0f;
yield return null;
while (Advertisement.isShowing)
yield return null;
Time.timeScale = currentTimeScale;
}
}
I initialized the ads in a different script on startup. My game is already on the google play store and I wish to fix this problem as soon as possible. So if anyone has any idea for what is causing this please, I need your help. Thank you!
Answer by Gokusansan · Sep 20, 2015 at 08:30 PM
That is because UnityAds is capable of finding that many advertisements in a fixed time for one device. You can work with multiple advertisement providers like Admob or MobileCore for being able to watch more ads in a row.
Then, is there a way for me to know if unity can produce more ads, through program$$anonymous$$g, so that I could request an ad from a different company when that happens?
Your answer
![](https://koobas.hobune.stream/wayback/20220612034205im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Facebook network banner ads in unity - any documentation/tutorials? 1 Answer
No data for this time period, Ads 0 Answers
Unity Ads Problem on android 0 Answers
Error when building Game 0 Answers
Ad platform - Appodeal, good or bad? 1 Answer