示例#1
0
        protected override void InternalDestroyBannerAd(AdPlacement placement)
        {
            #if EM_MOPUB
            if (placement.Equals(AdPlacement.Default)) // Default banner...
            {
                if (!mIsDefaultBannerAdReady)
                {
                    return;
                }

                MoPub.DestroyBanner(mAdSettings.DefaultBannerId.Id);
                mIsDefaultBannerAdReady = false;
            }
            else // Custom banner...
            {
                if (!mCustomBanners.ContainsKey(placement) || !mAdSettings.CustomBannerIds.ContainsKey(placement))
                {
                    return;
                }

                MoPub.DestroyBanner(mAdSettings.CustomBannerIds[placement].Id);
                mCustomBanners.Remove(placement);
            }
            #endif
        }
    private void CreateBannersSection()
    {
        const int titlePadding = 102;

        GUILayout.Space(titlePadding);
        GUILayout.Label("Banners");
        if (!IsAdUnitArrayNullOrEmpty(_bannerAdUnits))
        {
            foreach (var bannerAdUnit in _bannerAdUnits)
            {
                GUILayout.BeginHorizontal();

                GUI.enabled = !_adUnitToLoadedMapping[bannerAdUnit] || ForceEnableButtons;
                if (GUILayout.Button(CreateRequestButtonLabel(bannerAdUnit)))
                {
                    var position = _bannerPositions[_bannerPositionIndex++];
                    UpdateStatusLabel(string.Format("Requesting {0} at position {1}", bannerAdUnit, position));
                    MoPub.RequestBanner(bannerAdUnit, position, MoPub.MaxAdSize.Width336Height280);
                    _bannerPositionIndex %= _bannerPositions.Length;
                }

                GUI.enabled = _adUnitToLoadedMapping[bannerAdUnit] || ForceEnableButtons;
                if (GUILayout.Button("Destroy"))
                {
                    ClearStatusLabel();
                    MoPub.DestroyBanner(bannerAdUnit);
                    _adUnitToLoadedMapping[bannerAdUnit] = false;
                    _adUnitToShownMapping[bannerAdUnit]  = false;
                }

                GUI.enabled = _adUnitToLoadedMapping[bannerAdUnit] && !_adUnitToShownMapping[bannerAdUnit] || ForceEnableButtons;
                if (GUILayout.Button("Show"))
                {
                    ClearStatusLabel();
                    MoPub.ShowBanner(bannerAdUnit, true);
                    _adUnitToShownMapping[bannerAdUnit] = true;
                }

                GUI.enabled = _adUnitToLoadedMapping[bannerAdUnit] && _adUnitToShownMapping[bannerAdUnit] || ForceEnableButtons;
                if (GUILayout.Button("Hide"))
                {
                    ClearStatusLabel();
                    MoPub.ShowBanner(bannerAdUnit, false);
                    _adUnitToShownMapping[bannerAdUnit] = false;
                }

                GUI.enabled = true;

                GUILayout.EndHorizontal();
            }
        }
        else
        {
            GUILayout.Label("No banner AdUnits available", _smallerFont, null);
        }
    }
示例#3
0
 protected override bool DoDestoryAD()
 {
     if (string.IsNullOrEmpty(m_ADParams.adUnitId))
     {
         return(false);
     }
     MoPub.DestroyBanner(m_ADParams.adUnitId);
     m_ADState = ADState.Destory;
     return(true);
 }
示例#4
0
    private void CreateBannersSection()
    {
        const int titlePadding = 102;

        GUILayout.Space(titlePadding);
        GUILayout.Label("Banners");
        if (!IsAdUnitArrayNullOrEmpty(_bannerAdUnits))
        {
            foreach (var bannerAdUnit in _bannerAdUnits)
            {
                GUILayout.BeginHorizontal();

                GUI.enabled = !_adUnitToLoadedMapping[bannerAdUnit];
                if (GUILayout.Button(CreateRequestButtonLabel(bannerAdUnit)))
                {
                    Debug.Log("requesting banner with AdUnit: " + bannerAdUnit);
                    UpdateStatusLabel("Requesting " + bannerAdUnit);
                    MoPub.CreateBanner(bannerAdUnit, MoPub.AdPosition.BottomCenter);
                }

                GUI.enabled = _adUnitToLoadedMapping[bannerAdUnit];
                if (GUILayout.Button("Destroy"))
                {
                    ClearStatusLabel();
                    MoPub.DestroyBanner(bannerAdUnit);
                    _adUnitToLoadedMapping[bannerAdUnit] = false;
                    _adUnitToShownMapping[bannerAdUnit]  = false;
                }

                GUI.enabled = _adUnitToLoadedMapping[bannerAdUnit] && !_adUnitToShownMapping[bannerAdUnit];
                if (GUILayout.Button("Show"))
                {
                    ClearStatusLabel();
                    MoPub.ShowBanner(bannerAdUnit, true);
                    _adUnitToShownMapping[bannerAdUnit] = true;
                }

                GUI.enabled = _adUnitToLoadedMapping[bannerAdUnit] && _adUnitToShownMapping[bannerAdUnit];
                if (GUILayout.Button("Hide"))
                {
                    ClearStatusLabel();
                    MoPub.ShowBanner(bannerAdUnit, false);
                    _adUnitToShownMapping[bannerAdUnit] = false;
                }

                GUI.enabled = true;

                GUILayout.EndHorizontal();
            }
        }
        else
        {
            GUILayout.Label("No banner AdUnits available", _smallerFont, null);
        }
    }
示例#5
0
    public override void HideBanner(bool destroy)
    {
#if MOPUB
        if (!destroy)
        {
            MoPub.ShowBanner(_bannerAdUnits[0], false);
        }
        else
        {
            MoPub.DestroyBanner(_bannerAdUnits[0]);
        }
#endif
    }
示例#6
0
 /// <summary>
 /// Hides MoPub banner
 /// </summary>
 public void HideBanner()
 {
     MoPub.DestroyBanner(bannerAdUnit);
 }
示例#7
0
    public override void SubDispose()
    {
#if MOPUB
        MoPub.DestroyBanner(_bannerAdUnits[0]);
#endif
    }
 public void OnDestroy()
 {
     MoPub.DestroyBanner(bannerId);
 }
示例#9
0
 /// <summary>
 /// 摧毁banner
 /// </summary>
 private void DestoryBanner()
 {
     MoPub.DestroyBanner(currentBannerAdUnits);
 }
示例#10
0
    void OnGUI()
    {
        GUI.backgroundColor = Color.green;
        GUILayoutOption[] option = new GUILayoutOption[]
        {
            GUILayout.Height(80)
        };
        Texture2D texture = new Texture2D(128, 128);

        GUIStyle style = new GUIStyle(GUI.skin.button);

        style.normal.background = texture;
        Destroy(texture);
        style.normal.textColor = Color.yellow;
        style.fontSize         = 48;

        style.active.textColor = Color.blue;

        GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
        GUILayout.BeginVertical();

        GUILayout.Space(20);
        GUIStyle lableStyle = new GUIStyle();

        lableStyle.fontSize  = 56;
        lableStyle.alignment = TextAnchor.MiddleCenter;
        GUILayout.Label("Mopub + Vungle", lableStyle);

        if (GUILayout.Button("Init", style, option))
        {
            initMediation();
        }

        GUILayout.Space(20);
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Load Interstitial", style, option))
        {
            MoPub.RequestInterstitialAd(interstitialAdUnitId);
        }
        if (GUILayout.Button("Play Interstitial", style, option))
        {
            MoPub.ShowInterstitialAd(interstitialAdUnitId);
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(20);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Load Reward", style, option))
        {
            MoPub.RequestRewardedVideo(rewardAdUnitId);
        }
        if (GUILayout.Button("Play Reward", style, option))
        {
            MoPub.ShowRewardedVideo(rewardAdUnitId);
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(20);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Load Banner", style, option))
        {
            loadBanner();
        }
        if (GUILayout.Button("Play Banner", style, option))
        {
            playBanner();
        }
        if (GUILayout.Button("Destroy Banner", style, option))
        {
            MoPub.DestroyBanner(bannerAdUnitId);
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(20);

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Load MREC", style, option))
        {
            loadMREC();
        }
        if (GUILayout.Button("Play MREC", style, option))
        {
            playMREC();
        }
        if (GUILayout.Button("Destroy MREC", style, option))
        {
            MoPub.DestroyBanner(mrecAdUnitId);
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
示例#11
0
 private void DestroyBanner()
 {
     MoPub.DestroyBanner(_bannerAdUnits[0]);
 }
示例#12
0
 public void RemoveBanner()
 {
     MoPub.DestroyBanner(_adUnitId);
 }