// When interstitial window opens void OnPresentScreenInterstitial() { isInterstitialReady = false; isInterstitialVisible = true; if (hideBannerOnInterstitial) { AdmobAd.Instance().HideBannerAd(); } }
// Hide the banner advert from view public void hideBanner(bool overlapScreen = false) { // If this is an overlapping screen then remember the current banner state for when we close the overlapping window if (overlapScreen) { memBannerState = isBannerVisible; } // Just hiding the banner, it can also be re-shown again AdmobAd.Instance().HideBannerAd(); }
// Show the banner advert public void showBanner(bool overlapScreen = false, bool force = false) { // If this is not an overlapping screen with the previous banner state as hidden if (!(overlapScreen && !memBannerState)) { // Make sure we have a ready banner or we are forcing it if (isBannerReady || force) { AdmobAd.Instance().ShowBannerAd(); } } }
// Show the interstitial we have loaded public void showInterstitial(bool force = false) { // Make sure we have a ready interstitial or we are forcing it if (isInterstitialReady || force) { AdmobAd.Instance().ShowInterstitialAd(); } else { GoogleAnalytics.Instance.LogError("Interstital was requested but it wasn't ready", false); } }
// Load a interstitial advert from Google public void loadInterstitial(bool displayImmediately) { // Make sure there isn't already an interstitial advert loading or ready if (!isInterstitialLoading && !isInterstitialReady) { // Load the interstitial and send the displayImmediately bool AdmobAd.Instance().LoadInterstitialAd(!displayImmediately); // Set the interstitial loading variable so we know we have a interstitial loading isInterstitialLoading = true; } }
void Awake() { if (_instanceFound) { Destroy(gameObject); return; } _instanceFound = true; // The gameObject will retain... DontDestroyOnLoad(this); AdmobAd.Instance(); }
// When interstitial window is closed (Via hardware back button or clicking the X) void OnDismissScreenInterstitial() { isInterstitialVisible = false; if (hideBannerOnInterstitial) { AdmobAd.Instance().ShowBannerAd(); } if (keepInterstitialsLoaded) { loadInterstitial(false); } }
void Awake() { if (!Instance) { Instance = this; DontDestroyOnLoad(this); } else { Destroy(this.gameObject); Debug.LogWarning("You have duplicate AdMob Managers in your scene!"); } AdmobAdAgent.RetainGameObject(ref _instanceFound, gameObject, null); AdmobAd.Instance(); }
// Load a banner advert from Google public void loadBanner(AdmobAd.BannerAdType adSize, AdmobAd.AdLayout adPosition, bool displayImmediately = false) { // Make sure there isn't already a banner advert loading or ready if (!isBannerLoading && !isBannerReady) { // Load the banner advert with adSize and adPosition as requested AdmobAd.Instance().LoadBannerAd(adSize, adPosition); // Set the banner loading variable so we know we have a banner loading isBannerLoading = true; } if (displayImmediately) { showBanner(false, true); } }
void Awake() { if (Instance) { DebugLog("You have duplicate AdMob_Manager.cs scripts in your scene! Admob might not work as expected!"); Destroy(gameObject); return; } Instance = this; DontDestroyOnLoad(this); if (EnableAdMob) { AdmobAdAgent.RetainGameObject(ref AdMobAndroidReady, gameObject, null); AdIns = AdmobAd.Instance(); } }
void Start() { // Set the banner ID and interstitial ID for this app AdmobAd.Instance().Init(bannerID, interstitialID); // Check if adverts are enabled isAdvertsEnabled = AdmobAd.Instance().IsAdEnabled(); if (!isAdvertsEnabled) { enableAllAds(); } // LoadInterstitialAd takes a boolean stating if it should hold the advert until manually shown or not if (loadInterstitialOnStart) { loadInterstitial(showInterstitialOnStart); } }
void Start() { // Set the banner ID and interstitial ID for this app AdmobAd.Instance().Init(bannerID, interstitialID); // Check if adverts are enabled isAdvertsEnabled = AdmobAd.Instance().IsAdEnabled(); //TODO: my inserts loadBanner(AdmobAd.BannerAdType.Universal_Banner_320x50, AdmobAd.AdLayout.Top_Centered, true); //////////////// if (!isAdvertsEnabled) { enableAllAds(); } // LoadInterstitialAd takes a boolean stating if it should hold the advert until manually shown or not if (loadInterstitialOnStart) { loadInterstitial(showInterstitialOnStart); } //StartCoroutine(AdMob_Manager.Instance.waitForInterstitialLoad()); }
public void enableAllAds() { AdmobAd.Instance().EnableAd(); isAdvertsEnabled = true; }
// Disable all interstitials and banner adverts public void disableAllAds() { AdmobAd.Instance().DisableAd(); isAdvertsEnabled = false; }
// Destroy the banner advert public void destroyBanner() { isBannerReady = false; AdmobAd.Instance().DestroyBannerAd(); }
// Load a new banner advert public void refreshBanner() { // Note: Not yet sure if the banner is hidden whilst this loads a new ad or if the previous banner stays until refreshed AdmobAd.Instance().RefreshBannerAd(); }
void Awake() { // Do not modify the codes below. AdmobAdAgent.RetainGameObject(ref _instanceFound, gameObject, null); AdmobAd.Instance(); }
void OnGUI() { if (UnityEngine.GUI.Button(new Rect(10f, 100f, _buttonWidth, _buttonHeight), "Hide Banner")) { AdmobAd.Instance().HideBannerAd(); } if (UnityEngine.GUI.Button(new Rect(20f + _buttonWidth, 100f, _buttonWidth, _buttonHeight), "Show Banner")) { AdmobAd.Instance().ShowBannerAd(); } if (UnityEngine.GUI.Button(new Rect(30f + 2f * _buttonWidth, 100f, _buttonWidth, _buttonHeight), "Destroy Banner")) { AdmobAd.Instance().DestroyBannerAd(); } if (UnityEngine.GUI.Button(new Rect(10f, 200f, _buttonWidth, _buttonHeight), "Load Banner (Bottom)")) { AdmobAd.Instance().LoadBannerAd(AdmobAd.BannerAdType.Universal_SmartBanner, AdmobAd.AdLayout.Bottom_Centered); } if (UnityEngine.GUI.Button(new Rect(20f + _buttonWidth, 200f, _buttonWidth, _buttonHeight), "Load Banner (Top)")) { AdmobAd.Instance().LoadBannerAd(AdmobAd.BannerAdType.Universal_SmartBanner, AdmobAd.AdLayout.Top_Centered); } if (UnityEngine.GUI.Button(new Rect(30f + 2f * _buttonWidth, 200f, _buttonWidth, _buttonHeight), "Load Banner (MRect Center)")) { AdmobAd.Instance().LoadBannerAd(AdmobAd.BannerAdType.Tablets_IAB_MRect_300x250, AdmobAd.AdLayout.Middle_Centered); } if (UnityEngine.GUI.Button(new Rect(10f, 300f, _buttonWidth, _buttonHeight), "Load Banner (Bottom)\nWith Offset (0, 100)")) { AdmobAd.Instance().LoadBannerAd(AdmobAd.BannerAdType.Universal_SmartBanner, AdmobAd.AdLayout.Bottom_Centered, 0, 100, false, null); } if (UnityEngine.GUI.Button(new Rect(20f + _buttonWidth, 300f, _buttonWidth, _buttonHeight), "Load Banner (Top)\nWith Offset (0, 100)")) { AdmobAd.Instance().LoadBannerAd(AdmobAd.BannerAdType.Universal_SmartBanner, AdmobAd.AdLayout.Top_Centered, 0, 100, false, null); } if (UnityEngine.GUI.Button(new Rect(30f + 2f * _buttonWidth, 300f, _buttonWidth, _buttonHeight), "Move to Top")) { AdmobAd.Instance().RepositionBannerAd(AdmobAd.AdLayout.Top_Centered); } if (UnityEngine.GUI.Button(new Rect(10f, 400f, _buttonWidth, _buttonHeight), "Load & Show Interstitial")) { AdmobAd.Instance().LoadInterstitialAd(false); } if (UnityEngine.GUI.Button(new Rect(20f + _buttonWidth, 400f, _buttonWidth, _buttonHeight), "Load & Hide Interstitial")) { AdmobAd.Instance().LoadInterstitialAd(true); } if (UnityEngine.GUI.Button(new Rect(30f + 2f * _buttonWidth, 400f, _buttonWidth, _buttonHeight), "Show Interstitial")) { AdmobAd.Instance().ShowInterstitialAd(); } }