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 /
This question was closed Jun 10, 2018 at 01:03 PM by polan31 for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by polan31 · Jun 06, 2018 at 05:59 PM · admobadvertisingbanner

[Unity game admob] Why interstitial ad doesn't work?

I would like to put ads in my Unity game when OverSystem appears to me.

Unfortunately, interstitial ad doesn't work. Any help?

     private InterstitialAd interstitial;
 
     
     void Start ()
     {
         RequestInterstitial() ;
         GetComponent<AudioSource> ().playOnAwake = false;
         GetComponent<AudioSource> ().clip = destroySound;
 
     }
     public void OnCollisionEnter2D (Collision2D col)
     {
         
         collisionObject colObj= col.transform.GetComponent<collisionObject>();
 
         if(!colObj) return;
         CheckDestroyedIndex(colObj);
 
 
     }
     void CheckDestroyedIndex(collisionObject cObj) {
 
         if(index == cObj.myIndexNumber)
 
         {
             if (cObj.isHighestNumber)
 
             {
 
                 Debug.Log ("Yay you correctly hit the last Square, You WIN!");
                 WinSystem.SetActive (true);
                 gameObject.SetActive (false);
                 Manager.SetActive (false);
 
             }
 
             Destroy(cObj.gameObject);
             index++;
 
         }
         
         else
         {
 
             GameOver ();
             {
                 if (interstitial.IsLoaded()) {
                     interstitial.Show();
                 }
             }
         }
     }
 
     void GameOver (){
         ImageOver.SetActive (true);
         restartButton.SetActive (true);
         menuButton.SetActive (true);
         gameObject.SetActive (false);
         Manager.SetActive (false);
         WinSystem.SetActive (false);
     }
 
 
     private void RequestInterstitial()
     {
         #if UNITY_ANDROID
         string adUnitId = "ca-app-pub-3940256099942544/1033173712";
         #elif UNITY_IPHONE
         string adUnitId = "ca-app-pub-3940256099942544/4411468910";
         #else
         string adUnitId = "unexpected_platform";
         #endif
 
 
         // Clean up interstitial ad before creating a new one.
         if (this.interstitial != null) {
             this.interstitial.Destroy ();
         }
         // Initialize an InterstitialAd.
         InterstitialAd interstitial = new InterstitialAd(adUnitId);
         // Create an empty ad request.
         AdRequest request = new AdRequest.Builder().Build();
         // Load the interstitial with the request.
         interstitial.LoadAd(request);
 
 
         // Called when an ad request has successfully loaded.
         interstitial.OnAdLoaded += HandleOnAdLoaded;
         // Called when an ad request failed to load.
         interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;
         // Called when an ad is shown.
         interstitial.OnAdOpening += HandleOnAdOpened;
         // Called when the ad is closed.
         interstitial.OnAdClosed += HandleOnAdClosed;
 
         }
 
         public void HandleOnAdLoaded(object sender, EventArgs args)
         {
         MonoBehaviour.print("HandleAdLoaded event received");
         }
 
         public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
         {
         MonoBehaviour.print("HandleFailedToReceiveAd event received with message: "
         + args.Message);
         }
 
         public void HandleOnAdOpened(object sender, EventArgs args)
         {
         MonoBehaviour.print("HandleAdOpened event received");
         }
 
         public void HandleOnAdClosed(object sender, EventArgs args)
         {
         MonoBehaviour.print("HandleAdClosed event received");
         }
         }
     
 
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

2 Replies

  • Sort: 
avatar image
1

Answer by Getsumi3 · Jun 06, 2018 at 07:44 PM

Here is a good explanation on how to work with addmob in Unity


Just scroll down until you'll find "Quick Start" and follow the examples

https://github.com/unity-plugins/Unity-Admob

And check this video tutorial. It helped me when I tried to figure out on how to work with addmob and other google play services
https://www.youtube.com/watch?v=khlROw-PfNE

Comment
Add comment · Show 3 · Share
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
avatar image polan31 · Jun 06, 2018 at 11:41 PM 0
Share

Thanks for the answer, I've already checked this video, but unfortunately the DontDestroyOnLoad function does not work for me.

Every time I change the scene, it's removed.

avatar image Getsumi3 polan31 · Jun 07, 2018 at 10:05 AM 0
Share

Well then.
In your main menu create an empty object. Name it something like "Add$$anonymous$$anager". Attach you script that contain DontDestroyOnLoad to that object.

For more info about DontDestroyOnLoad check the documentation https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html

avatar image polan31 Getsumi3 · Jun 07, 2018 at 08:04 PM 0
Share

Yes, I know ( like on the video), but this video only works in the old version of Unity.

avatar image
0

Answer by Equalent · Jun 08, 2018 at 03:59 PM

Well, there is a great guide on using AdMob with Unity written by Google: link text. You just need to import the package and use it as described in the article.

Comment
Add comment · Show 1 · Share
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
avatar image polan31 · Jun 08, 2018 at 04:07 PM 0
Share

this is a tutorial that I don't understand :) I have already checked all these tutorials from the first pages of Google :)

Follow this Question

Answers Answers and Comments

84 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

Related Questions

Can we show 3d ads in the game like on billboards? 0 Answers

Displaying Admob's banner ad in game scene 0 Answers

Google Mobile Ads Interstitial ads is not showing in unity 2 Answers

Do Dummy notifications mean admob ads will load when launched? 0 Answers

Banner Ad Without Button 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