I am implementing Unity Ads very first time. I would like to know if I need to load/refill next ad (Banner, Interstitial and Rewarded) explicitly or Unity Ads SDK does it automatically. As this is the case with Google Mobile Ads SDK, where it is recommended to destroy and initialize Ad object after every impression shown to player. Unfortunately I cannot test Unity Ads for this scenario as even on Alpha/Beta testing on test device it again and again shows same test ads and not the production grade test ads (e.g. AdMob shows different ads every time even on a device which is added as test device). But with Unity Ads I don’t have any way to know if a different ad/impression has been loaded next time.
1 Like
Hi @OblicaStudio , thanks for asking!
In my implementation, I include a request to load subsequent ads in the OnUnityAdsShowComplete callback.
I hope this helps. Have a great day!
Hello, what do you mean by “I include a request to load subsequent ads”?
Do we need to load an ad everytime one has been displayed?
Is it correct to do it like this:
public void LoadAd()
{
// IMPORTANT! Only load content AFTER initialization (in this example, initialization is handled in a different script).
//Debug.Log("Loading Ad: " + _adUnitId);
Advertisement.Load(_adUnitId, this);
}
public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
{
//Load next ad
LoadAd();
}
Hi @MayIAsk ,
Yes, that looks good to me
This is the code I use in my test project if you’re curious.
public void LoadAd()
{
Debug.Log("Loading Ad: " + _adUnitId);
Advertisement.Load(_adUnitId, this);
}
public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
{
LoadAd();
if (adUnitId.Equals(_adUnitId) && showCompletionState.Equals(UnityAdsShowCompletionState.COMPLETED))
{
Debug.Log("Unity Ads Rewarded Ad Completed");
}
else if (adUnitId.Equals(_adUnitId) && showCompletionState.Equals(UnityAdsShowCompletionState.SKIPPED))
{
Debug.Log("Unity Ads Rewarded Ad Skipped");
}
else if (adUnitId.Equals(_adUnitId) && showCompletionState.Equals(UnityAdsShowCompletionState.UNKNOWN))
{
Debug.Log("Unity Ads Rewarded Ad Unknown status");
}
}
2 Likes