Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Advertisements;
- public class Ads : Money {
- void Update()
- {
- Advertisement.Initialize("1424659");
- }
- public void ShowRewardedAd()
- {
- if (Advertisement.IsReady("rewardedVideo"))
- {
- var options = new ShowOptions { resultCallback = HandleShowResult };
- Advertisement.Show("rewardedVideo", options);
- }
- }
- private void HandleShowResult(ShowResult result)
- {
- switch (result)
- {
- case ShowResult.Finished:
- money = money + 90;
- PlayerPrefs.GetInt("money", money);
- PlayerPrefs.SetInt("money", money);
- Debug.Log("The ad was successfully shown.");
- 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;
- }
- }
- }
Add Comment
Please, Sign In to add comment