Guest User

Untitled

a guest
Nov 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Advertisements;
  5.  
  6.  
  7.  
  8. public class Ads : Money {
  9.  
  10.  
  11.  
  12. void Update()
  13. {
  14. Advertisement.Initialize("1424659");
  15. }
  16.  
  17. public void ShowRewardedAd()
  18. {
  19. if (Advertisement.IsReady("rewardedVideo"))
  20. {
  21. var options = new ShowOptions { resultCallback = HandleShowResult };
  22. Advertisement.Show("rewardedVideo", options);
  23. }
  24. }
  25.  
  26. private void HandleShowResult(ShowResult result)
  27. {
  28. switch (result)
  29. {
  30. case ShowResult.Finished:
  31. money = money + 90;
  32. PlayerPrefs.GetInt("money", money);
  33. PlayerPrefs.SetInt("money", money);
  34. Debug.Log("The ad was successfully shown.");
  35. break;
  36. case ShowResult.Skipped:
  37. Debug.Log("The ad was skipped before reaching the end.");
  38. break;
  39. case ShowResult.Failed:
  40. Debug.LogError("The ad failed to be shown.");
  41. break;
  42. }
  43. }
  44. }
Add Comment
Please, Sign In to add comment