Unity Ads: Rewarded video is not ready.
Hello, i have a problem with rewarded video ads. I dont see nothing wrong...
My code is:
public void WatchVideoForCoinButtonClick()
{
// avoid multiple click
if (clicking == true) return;
clicking = true;
StartCoroutine(ResetButtonClick());
if (Advertisement.IsReady("rewardedVideo"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show("rewardedVideo", options);
}
else
{
Debug.Log("Unity Ads: Rewarded video is not ready.");
}
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("Unity Ads: The ad was successfully shown.");
// plus coin
GameData.instance.SavePlayerCoin(GameData.instance.GetPlayerCoin() + Configure.instance.watchVideoCoin);
// play add coin sound
AudioManager.instance.CoinAddAudio();
// update text label
UpdateCoinAmountLabel();
break;
case ShowResult.Skipped:
Debug.Log("Unity Ads: The ad was skipped before reaching the end.");
break;
case ShowResult.Failed:
Debug.LogError("Unity Ads: The ad failed to be shown.");
break;
}
}
Comment
I'm using the built-in unity ads, (not the asset), and displaying regular video ads. Adding: Advertisement.Initialize(Advertisement.gameId); fixed this for me. The weird part is that in another project the ads work with out the init.
Answer by LandonC · Mar 17, 2017 at 08:54 AM
I had the issue and solve it with a coroutine.
Try this:
IEnumerator ShowAdWhenReady()
{
while (!Advertisement.IsReady("rewardedVideo"))
yield return null;
ShowOptions options = new ShowOptions();
options.resultCallback = AdCallbackhandler;
Advertisement.Show ("rewardedVideo", options);
}
public void ShowAd(string zone = "")
{
StartCoroutine(ShowAdWhenReady());
}
Your answer
Follow this Question
Related Questions
UnityAds.initialize() FPS drops on iOS 0 Answers
Unity Ads GameID?? 0 Answers
How to fix xcode banner position error (unity ads) 2 Answers
Unity Ads Vs Unity Ads 2.0 0 Answers