Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. void Start()
  2. {
  3. AdMobRewardedAd = RewardBasedVideoAd.Instance;
  4. // Called when an ad request has successfully loaded.
  5. AdMobRewardedAd.OnAdLoaded += HandleRewardBasedVideoLoaded;
  6. // Called when an ad request failed to load.
  7. AdMobRewardedAd.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
  8. // Called when an ad is shown.
  9. AdMobRewardedAd.OnAdOpening += HandleRewardBasedVideoOpened;
  10. // Called when the ad starts to play.
  11. AdMobRewardedAd.OnAdStarted += HandleRewardBasedVideoStarted;
  12. // Called when the user should be rewarded for watching a video.
  13. AdMobRewardedAd.OnAdRewarded += HandleRewardBasedVideoRewarded;
  14. // Called when the ad is closed.
  15. AdMobRewardedAd.OnAdClosed += HandleRewardBasedVideoClosed;
  16. // Called when the ad click caused the user to leave the application.
  17. AdMobRewardedAd.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
  18. // Initialize the Google Mobile Ads SDK.
  19. MobileAds.Initialize(appId);
  20.  
  21. this.Load_rewarded_video();
  22. }
  23. //Google ad mob Handlers======================
  24. public void HandleRewardBasedVideoLoaded(object sender, EventArgs args)
  25. {
  26. //MonoBehaviour.print("HandleRewardBasedVideoLoaded event received");
  27. }
  28. public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args)
  29. {
  30. Time.timeScale = 1;
  31. //MonoBehaviour.print(
  32. // "HandleRewardBasedVideoFailedToLoad event received with message: "
  33. // + args.Message);
  34. }
  35. public void HandleRewardBasedVideoOpened(object sender, EventArgs args)
  36. {
  37. //MonoBehaviour.print("HandleRewardBasedVideoOpened event received");
  38. }
  39. public void HandleRewardBasedVideoStarted(object sender, EventArgs args)
  40. {
  41. //MonoBehaviour.print("HandleRewardBasedVideoStarted event received");
  42. }
  43. public void HandleRewardBasedVideoClosed(object sender, EventArgs args)
  44. {
  45. //MonoBehaviour.print("HandleRewardBasedVideoClosed event received");
  46. Time.timeScale = 1;
  47.  
  48. this.Load_rewarded_video();
  49.  
  50. }
  51. public void HandleRewardBasedVideoRewarded(object sender, Reward args)
  52. {
  53. Time.timeScale = 1;
  54. ContinueGameCalculations();
  55. }
  56. public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args)
  57. {
  58. //MonoBehaviour.print("HandleRewardBasedVideoLeftApplication event received");
  59. }
  60. private void Load_rewarded_video()
  61. {
  62. #if UNITY_IOS
  63. string ad_unit = "ca-app-pub-5759662936419616/3614417629";
  64. #endif
  65. AdMobRewardedAd.LoadAd(new AdRequest.Builder().Build(), ad_unit);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement