コード例 #1
0
    // When interstitial window opens
    void OnPresentScreenInterstitial()
    {
        isInterstitialReady   = false;
        isInterstitialVisible = true;

        if (hideBannerOnInterstitial)
        {
            AdmobAd.Instance().HideBannerAd();
        }
    }
コード例 #2
0
    // 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();
    }
コード例 #3
0
 // 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();
         }
     }
 }
コード例 #4
0
 // 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);
     }
 }
コード例 #5
0
    // 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;
        }
    }
コード例 #6
0
 void Awake()
 {
     if (_instanceFound)
     {
         Destroy(gameObject);
         return;
     }
     _instanceFound = true;
     // The gameObject will retain...
     DontDestroyOnLoad(this);
     AdmobAd.Instance();
 }
コード例 #7
0
    // 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);
        }
    }
コード例 #8
0
    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();
    }
コード例 #9
0
    // 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);
        }
    }
コード例 #10
0
    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();
        }
    }
コード例 #11
0
    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);
        }
    }
コード例 #12
0
    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());
    }
コード例 #13
0
 public void enableAllAds()
 {
     AdmobAd.Instance().EnableAd();
     isAdvertsEnabled = true;
 }
コード例 #14
0
 // Disable all interstitials and banner adverts
 public void disableAllAds()
 {
     AdmobAd.Instance().DisableAd();
     isAdvertsEnabled = false;
 }
コード例 #15
0
    // Destroy the banner advert
    public void destroyBanner()
    {
        isBannerReady = false;

        AdmobAd.Instance().DestroyBannerAd();
    }
コード例 #16
0
 // 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();
 }
コード例 #17
0
 void Awake()
 {
     // Do not modify the codes below.
     AdmobAdAgent.RetainGameObject(ref _instanceFound, gameObject, null);
     AdmobAd.Instance();
 }
コード例 #18
0
    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();
        }
    }