Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 YassinAH · Apr 27 at 01:34 PM · unity5

Insert Interstitial between scenes and close the ad before changing the scenes in Unity,

I'm using AdMob interstitial ads, everything works fine. unfortunately the ad appears for about 1 second and disappears then scene is loaded. The user has no time to close the ad. What condition can I use if I want the scene to load only after the ad is closed?

 using System.Collections;
         using System.Collections.Generic;
         using UnityEngine;
         using UnityEngine.SceneManagement;
         using GoogleMobileAds.Api;
         using UnityEngine.UI;
         using System;
     
     public class AdManager : MonoBehaviour
     {
         public static AdManager Instance { get; set; }
     
         
         private InterstitialAd interstitial;
         
     
     
     void Start()
     {
         #if UNITY_ANDROID
             string appId = "";
         #elif UNITY_IPHONE
             string appId = "todo";
         #else
             string appId = "";
         #endif
         
         this.interstitial = new InterstitialAd(appId);
     }
     
     public void ShowInterstitial()
     {
         RequestInterstitial();
     
     } 
     
     
     
     public void RequestInterstitial()
     {
         #if UNITY_ANDROID
             string interstitialId = "ca-app-pub-3940256099942544/1033173712";
         #elif UNITY_IPHONE
             string interstitialId = "unexpected_platform";
         #else
             string interstitialId = "unexpected_platform";
         #endif
     
         if(interstitial !=null)
         interstitial.Destroy();
     
         interstitial = new InterstitialAd(interstitialId);
     
         interstitial.OnAdLoaded +=HandleOnAdLoaded;
     
         interstitial.LoadAd(CreateNewRequest());
     
     }
     public void HandleOnAdLoaded(object sender, EventArgs args)
     {
         if(interstitial.IsLoaded())
         interstitial.Show();
     }
         
     
     private AdRequest CreateNewRequest()
     {
         return new AdRequest.Builder().Build();
     
     }
     
     
     }

//Change scene code I am using:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 public class ChangeScene : MonoBehaviour
 {
 
 public void LoadScene(string sceneName)
 {
     
     SceneManager.LoadScene(sceneName);
     
 }
 
 }


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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Hawaii_Dev · Apr 28 at 07:44 AM

The google docs:https://developers.google.com/admob/unity/interstitial Under ad events, you will find an event called: OnAdClosed. Add this event to your code and call the change scene script when that event fire.

@YassinAH

Comment
Add comment · 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

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

160 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 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

Error while Running on Ios device with 64 bit processor (ipad air, iphone 6) 0 Answers

Problem After Building Game In Unity 5 1 Answer

Manual Activation for Unity5 when no internet 1 Answer

No realtime shadows in webplayer build? 0 Answers

How to calculate ship position and rotation in a pipeline with raycasts 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