Hi,
Simply put I have got the “Simple ads” to work using the code snippet in the editor but the “rewarded ads” code snippet doesn’t. “Advertisment.IsReady” is NEVER ready. I’ve tested this in editor and on device and still no luck. Just for clarity’s sake I’m calling the “public void ShowRewardedAd()” function from a UI button.
Here’s the code…
using UnityEngine;
using UnityEngine.Advertisements;
public class UnityAdsExample : MonoBehaviour
{
public void ShowRewardedAd()
{
if (Advertisement.IsReady ("rewardedVideoZone")) {
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show ("rewardedVideoZone", options);
} else
Debug.Log ("Im Not Ready");
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("The ad was successfully shown.");
//
// YOUR CODE TO REWARD THE GAMER
// Give coins etc.
break;
case ShowResult.Skipped:
Debug.Log("The ad was skipped before reaching the end.");
break;
case ShowResult.Failed:
Debug.LogError("The ad failed to be shown.");
break;
}
}
}
Thanks for the help.