Will this script work without doing anything other than this? Because I have no idea what is meant with rewarded videozone. Could someone please tell me?
The ShowRewardedAd function is attached to a button by the way.
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
public class Ads : MonoBehaviour
{
int coin;
void Start ()
{
coin = PlayerPrefs.GetInt ("Coins");
}
public void ShowRewardedAd()
{
if (Advertisement.IsReady ("rewardedVideoZone"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show ("rewardedVideoZone", options);
}
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log ("The ad was successfully shown.");
coin += 5;
PlayerPrefs.SetInt ("Coins", coin);
PlayerPrefs.Save ();
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 in advance for your help!