Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Start()
- {
- AdMobRewardedAd = RewardBasedVideoAd.Instance;
- // Called when an ad request has successfully loaded.
- AdMobRewardedAd.OnAdLoaded += HandleRewardBasedVideoLoaded;
- // Called when an ad request failed to load.
- AdMobRewardedAd.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
- // Called when an ad is shown.
- AdMobRewardedAd.OnAdOpening += HandleRewardBasedVideoOpened;
- // Called when the ad starts to play.
- AdMobRewardedAd.OnAdStarted += HandleRewardBasedVideoStarted;
- // Called when the user should be rewarded for watching a video.
- AdMobRewardedAd.OnAdRewarded += HandleRewardBasedVideoRewarded;
- // Called when the ad is closed.
- AdMobRewardedAd.OnAdClosed += HandleRewardBasedVideoClosed;
- // Called when the ad click caused the user to leave the application.
- AdMobRewardedAd.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
- // Initialize the Google Mobile Ads SDK.
- MobileAds.Initialize(appId);
- this.Load_rewarded_video();
- }
- //Google ad mob Handlers======================
- public void HandleRewardBasedVideoLoaded(object sender, EventArgs args)
- {
- //MonoBehaviour.print("HandleRewardBasedVideoLoaded event received");
- }
- public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args)
- {
- Time.timeScale = 1;
- //MonoBehaviour.print(
- // "HandleRewardBasedVideoFailedToLoad event received with message: "
- // + args.Message);
- }
- public void HandleRewardBasedVideoOpened(object sender, EventArgs args)
- {
- //MonoBehaviour.print("HandleRewardBasedVideoOpened event received");
- }
- public void HandleRewardBasedVideoStarted(object sender, EventArgs args)
- {
- //MonoBehaviour.print("HandleRewardBasedVideoStarted event received");
- }
- public void HandleRewardBasedVideoClosed(object sender, EventArgs args)
- {
- //MonoBehaviour.print("HandleRewardBasedVideoClosed event received");
- Time.timeScale = 1;
- this.Load_rewarded_video();
- }
- public void HandleRewardBasedVideoRewarded(object sender, Reward args)
- {
- Time.timeScale = 1;
- ContinueGameCalculations();
- }
- public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args)
- {
- //MonoBehaviour.print("HandleRewardBasedVideoLeftApplication event received");
- }
- private void Load_rewarded_video()
- {
- #if UNITY_IOS
- string ad_unit = "ca-app-pub-5759662936419616/3614417629";
- #endif
- AdMobRewardedAd.LoadAd(new AdRequest.Builder().Build(), ad_unit);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement