Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sabbireal · May 02, 2019 at 08:22 AM · performanceadsadmobofflineslowdown

Admob reward based video ad performance problem in offline mode

Help please. I have created a script to add a resume funtion for users by seeing an reward base ad from Admob in unity. It works fine when user is online. but performance is too slow (not playable) when user device is in offline mode.

When the script is disable game works fine in both online and offline. The problem maybe in RequestRewardBasedVideo() funtion.

 using System;
 using UnityEngine;
 using GoogleMobileAds.Api;
 using UnityEngine.SceneManagement;
 using UnityEngine.UI;
 
 public class RewardAdResume : MonoBehaviour
 {
     private string app_id = "....................";
     private RewardBasedVideoAd rewardBasedVideo;
 
     public rewdResume RewdResume;
     public bool adClosed;
     public Text txt2;
 
     public GameObject ops;
     public GameObject rw1;
     public GameObject rw2;
     public GameObject rw3;
 
     public bool opsld;
     public GameObject opsLdImg;
 
     // Start is called before the first frame update
     void Start()
     {
         //on publish enable
         //MobileAds.Initialize(app_id);
 
         adClosed = false;
         opsld = false;
         this.RequestRewardBasedVideo();
     }
 
     void Update()
     {
         if (adClosed)
         {
             if (rewdResume.resumes)
             {
                 txt2.text = adClosed + " Rewarded " + rewdResume.resumes;
                 RewdResume.resume();
                 rewdResume.resumes = false;
             }
             else
             {
                 roverCore.adclosed = true;
             }
             adClosed = false;
         }
 
 
         if (opsld) {
             opsLdImg.GetComponent<Image>().fillAmount += Time.deltaTime * 0.2f;
             if (opsLdImg.GetComponent<Image>().fillAmount == 1) {
                 roverCore.adclosed = true;
 
                 ops.SetActive(false);
                 rw1.SetActive(true);
                 rw2.SetActive(true);
                 rw3.SetActive(true);
 
                 opsld = false;
             }
         }
     }
 
 
     private void RequestRewardBasedVideo()
     {
         string adUnitId = "ca-app-pub-3940256099942544/5224354917";
         this.rewardBasedVideo = RewardBasedVideoAd.Instance;
 
         // Called when an ad request has successfully loaded.
         rewardBasedVideo.OnAdLoaded += HandleRewardBasedVideoLoaded;
         // Called when an ad request failed to load.
         rewardBasedVideo.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
         // Called when an ad is shown.
         rewardBasedVideo.OnAdOpening += HandleRewardBasedVideoOpened;
         // Called when the ad starts to play.
         rewardBasedVideo.OnAdStarted += HandleRewardBasedVideoStarted;
         // Called when the user should be rewarded for watching a video.
         rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
         // Called when the ad is closed.
         rewardBasedVideo.OnAdClosed += HandleRewardBasedVideoClosed;
         // Called when the ad click caused the user to leave the application.
         rewardBasedVideo.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
 
         // Create an empty ad request.
         AdRequest adRequest = new AdRequest.Builder().AddTestDevice("2077ef9a63d2b398840261c8221a0c9b").Build();
 
         // Load the rewarded video ad with the request.
         this.rewardBasedVideo.LoadAd(adRequest, adUnitId);
     }
 
 
     public void UserOptToWatchAd()
     {
         if (rewardBasedVideo.IsLoaded())
         {
             roverCore.showChanceTimeout = false;
             rewardBasedVideo.Show();
         }
         else {
             ops.SetActive(true);
             rw1.SetActive(false);
             rw2.SetActive(false);
             rw3.SetActive(false);
             opsld = true;
             //roverCore.adclosed = true;
         }
     }
 
     #region rewd event
 
     public void HandleRewardBasedVideoLoaded(object sender, EventArgs args)
     {
         MonoBehaviour.print("HandleRewardBasedVideoLoaded event received");
     }
 
     public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args)
     {
         this.RequestRewardBasedVideo();
     }
 
     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)
     {
 
         adClosed = true;
     }
 
     public void HandleRewardBasedVideoRewarded(object sender, Reward args)
     {
         rewdResume.resumes = true;
     }
 
     public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args)
     {
         MonoBehaviour.print("HandleRewardBasedVideoLeftApplication event received");
     }
 
     #endregion
 
     private void OnDisable()
     {
         // Called when an ad request has successfully loaded.
         rewardBasedVideo.OnAdLoaded -= HandleRewardBasedVideoLoaded;
         // Called when an ad request failed to load.
         rewardBasedVideo.OnAdFailedToLoad -= HandleRewardBasedVideoFailedToLoad;
         // Called when an ad is shown.
         rewardBasedVideo.OnAdOpening -= HandleRewardBasedVideoOpened;
         // Called when the ad starts to play.
         rewardBasedVideo.OnAdStarted -= HandleRewardBasedVideoStarted;
         // Called when the user should be rewarded for watching a video.
         rewardBasedVideo.OnAdRewarded -= HandleRewardBasedVideoRewarded;
         // Called when the ad is closed.
         rewardBasedVideo.OnAdClosed -= HandleRewardBasedVideoClosed;
         // Called when the ad click caused the user to leave the application.
         rewardBasedVideo.OnAdLeavingApplication -= HandleRewardBasedVideoLeftApplication;
     }
 }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

124 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Implementing AdMob into Android Mobile Games 1 Answer

Interstitial showing only once [AdMob] 1 Answer

ADMob ads no show 3 Answers

admob ads not showing (edit - plzz someone help) 2 Answers

do dummy ads mean real ads will load 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges