Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 nikayout · Feb 08, 2015 at 09:39 PM · adsadmob

Interstitial After GameOver

Hello i have inserted interstitial and banner ads into game ads are showing when you click button, i need to load and start ad after scene starts here is my code please help how can i edit it

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(AdMobPlugin))]
 public class Menu : MonoBehaviour {
 
     private const string AD_UNIT_ID = "";
     private const string INTERSTITIAL_ID = "";
 
     private static Vector2 BUTTON_SIZE = new Vector2(100, 50);
 
     private Rect buttonPositionShowAds;
     private Rect buttonPositionHideAds;
     private Rect buttonPositionShowInterstitial;
 
     private AdMobPlugin admob;
 
     void Start() {
         admob = GetComponent<AdMobPlugin>();
         admob.CreateBanner(adUnitId: AD_UNIT_ID,
                            adSize: AdMobPlugin.AdSize.SMART_BANNER,
                            isTopPosition: true,
                            interstitialId: INTERSTITIAL_ID,
                            isTestDevice: false);
         admob.RequestAd();
 
         buttonPositionShowAds = new Rect(
             (Screen.width - BUTTON_SIZE.x) / 2,
             (Screen.height - BUTTON_SIZE.y) / 2,
             BUTTON_SIZE.x, BUTTON_SIZE.y);
 
         buttonPositionHideAds = new Rect(
             buttonPositionShowAds.x, buttonPositionShowAds.y + BUTTON_SIZE.y * 3 / 2,
             buttonPositionShowAds.width, buttonPositionShowAds.height);
 
         buttonPositionShowInterstitial = new Rect(
             buttonPositionHideAds.x, buttonPositionHideAds.y + BUTTON_SIZE.y * 3 / 2,
             buttonPositionHideAds.width, buttonPositionHideAds.height);
     }
 
     void OnEnable() {
         AdMobPlugin.AdClosed += () => { Debug.Log ("AdClosed"); };
         AdMobPlugin.AdFailedToLoad += () => { Debug.Log ("AdFailedToLoad"); };
         AdMobPlugin.AdLeftApplication += () => { Debug.Log ("AdLeftApplication"); };
         AdMobPlugin.AdOpened += () => { Debug.Log ("AdOpened"); };
 
         AdMobPlugin.InterstitialClosed += () => { Debug.Log ("InterstitialClosed"); };
         AdMobPlugin.InterstitialFailedToLoad += () => { Debug.Log ("InterstitialFailedToLoad"); };
         AdMobPlugin.InterstitialLeftApplication += () => { Debug.Log ("InterstitialLeftApplication"); };
         AdMobPlugin.InterstitialOpened += () => { Debug.Log ("InterstitialOpened"); };
 
         AdMobPlugin.AdLoaded += HandleAdLoaded;
         AdMobPlugin.InterstitialLoaded += HandleInterstitialLoaded;
     }
 
     void OnDisable() {
         AdMobPlugin.AdLoaded -= HandleAdLoaded;
         AdMobPlugin.InterstitialLoaded -= HandleInterstitialLoaded;
     }
 
     void HandleAdLoaded() {
 #if !UNITY_EDITOR
         admob.ShowBanner();
 #endif
     }
 
     void HandleInterstitialLoaded() {
 #if !UNITY_EDITOR
         admob.ShowInterstitial();
 #endif
     }
 
     void OnGUI() {
         if (GUI.Button(buttonPositionShowAds, "Show Ads")) {
 #if !UNITY_EDITOR
             admob.ShowBanner();
 #endif
         }
 
         if (GUI.Button(buttonPositionHideAds, "Hide Ads")) {
 #if !UNITY_EDITOR
             admob.HideBanner();
 #endif
         }
 
         if (GUI.Button(buttonPositionShowInterstitial, "Show Interstitial")) {
 #if !UNITY_EDITOR
             admob.RequestInterstitial();
 #endif
         }
     }
 }
 
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

2 People are following this question.

avatar image avatar image

Related Questions

what do you do after setting up admob in the unity editor 0 Answers

Admob ads not showing when using Unity 2018 0 Answers

Banner AdMob is not showing on Android 1 Answer

Admob iOS Rewarded Videos don't close 0 Answers

Banner Ads which contain animated ads affect the performance of the game !! 2 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