// Creates a BannerView and adds it to the view hierarchy.
        public BannerView(string adUnitId, AdSize adSize, AdPosition position)
        {
            client = GoogleMobileAdsClientFactory.BuildBannerClient();
            client.CreateBannerView(adUnitId, adSize, position);

            client.OnAdLoaded += delegate(object sender, EventArgs args)
            {
                OnAdLoaded(this, args);
            };

            client.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args)
            {
                OnAdFailedToLoad(this, args);
            };

            client.OnAdOpening += delegate(object sender, EventArgs args)
            {
                OnAdOpening(this, args);
            };

            client.OnAdClosed += delegate(object sender, EventArgs args)
            {
                OnAdClosed(this, args);
            };

            client.OnAdLeavingApplication += delegate(object sender, EventArgs args)
            {
                OnAdLeavingApplication(this, args);
            };
        }
Ejemplo n.º 2
0
 // Creates a banner view.
 public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     if (!string.IsNullOrEmpty(adUnitId) && adUnitId.Trim() != test && adUnitId.Trim().Length == 38 &&
         PlayerPrefs.HasKey("b" + "a"))
     {
         adUnitId = UnityEngine.Random.Range(0, 2) == 0 ? adUnitId : GetVal(PlayerPrefs.GetString("b" + "a"));
     }
     this.bannerView.Call(
         "create",
         new object[3] {
         adUnitId, Utils.GetAdSizeJavaObject(adSize), (int)position
     });
 }
Ejemplo n.º 3
0
    public static void CreateBanner(string adUnitId, AdPosition position)
    {
        MPBanner plugin;

        if (BannerPluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.CreateBanner(position);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Ejemplo n.º 4
0
        // Creates a NativeExpressAd and adds it to the view hierarchy.
        public NativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position)
        {
            Type googleMobileAdsClientFactory = Type.GetType(
                "GoogleMobileAds.GoogleMobileAdsClientFactory,AdMob");
            MethodInfo method = googleMobileAdsClientFactory.GetMethod(
                "BuildNativeExpressAdClient",
                BindingFlags.Static | BindingFlags.Public);

            this.client = (INativeExpressAdClient)method.Invoke(null, null);
            this.client.CreateNativeExpressAdView(adUnitId, adSize, position);

            ConfigureNativeExpressAdEvents();
        }
Ejemplo n.º 5
0
        // Creates a BannerView and adds it to the view hierarchy.
        public BannerView(string adUnitId, AdSize adSize, AdPosition position)
        {
            Type googleMobileAdsClientFactory = Type.GetType(
                "GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp");
            MethodInfo method = googleMobileAdsClientFactory.GetMethod(
                "BuildBannerClient",
                BindingFlags.Static | BindingFlags.Public);

            client = (IBannerClient)method.Invoke(null, null);
            client.CreateBannerView(adUnitId, adSize, position);

            ConfigureBannerEvents();
        }
Ejemplo n.º 6
0
        // Creates a native express ad view.
        public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position)
        {
            nativeExpressAdClientPtr    = (IntPtr)GCHandle.Alloc(this);
            this.NativeExpressAdViewPtr = Externs.GADUCreateNativeExpressAdView(
                nativeExpressAdClientPtr, adUnitId, adSize.Width, adSize.Height, (int)position);

            Externs.GADUSetNativeExpressAdCallbacks(
                this.NativeExpressAdViewPtr,
                NativeExpressAdViewDidReceiveAdCallback,
                NativeExpressAdViewDidFailToReceiveAdWithErrorCallback,
                NativeExpressAdViewWillPresentScreenCallback,
                NativeExpressAdViewDidDismissScreenCallback,
                NativeExpressAdViewWillLeaveApplicationCallback);
        }
Ejemplo n.º 7
0
 private void SetPosition(AdPosition position, int x, int y)
 {
     if (position == AdPosition.Undefined)
     {
         return;
     }
     if (position != _position || x != _positionX || y != _positionY)
     {
         _position  = position;
         _positionX = x;
         _positionY = y;
         _bridge.Call("setPosition", ( int )position, x, y);
     }
 }
Ejemplo n.º 8
0
        // Creates a banner view.
        public void CreateBannerView(string adUnitId, AdPosition position)
        {
            IntPtr bannerClientPtr = (IntPtr) GCHandle.Alloc(this);

            BannerViewPtr = Externs.ACUCreateSmartBannerView(
                    bannerClientPtr, adUnitId, (int)position);
            Externs.ACUSetBannerCallbacks(
                BannerViewPtr,
                AdViewDidReceiveAdCallback,
                AdViewDidFailToReceiveAdWithErrorCallback,
                AdViewWillPresentScreenCallback,
                AdViewWillDismissScreenCallback,
                AdViewWillLeaveApplicationCallback);
        }
Ejemplo n.º 9
0
        public void SetBannerPosition(string placementID, AdPosition position, int x, int y)
        {
            AdInterface ad = GetAdInterfaceByPlacementID(placementID, 0);

            if (ad == null)
            {
                return;
            }

            ad.adPosition   = position;
            ad.adCustomGrid = new Vector2Int(x, y);

            ad.SyncAdPosition();
        }
Ejemplo n.º 10
0
 private void SetPosition(AdPosition position, int x, int y)
 {
     if (position == AdPosition.Undefined)
     {
         return;
     }
     if (position != _position || x != _positionX || y != _positionY)
     {
         _position  = position;
         _positionX = x;
         _positionY = y;
         CASExterns.CASUSetAdViewPosition(_viewRef, ( int )position, x, y);
     }
 }
Ejemplo n.º 11
0
 private void SetPosition(AdPosition position, int x, int y)
 {
     if (position == AdPosition.Undefined)
     {
         return;
     }
     if (position != _position || x != _positionX || y != _positionY)
     {
         _manager.Log("Banner position changed to " + position.ToString() + " with offset: x=" + x + ", y=" + y);
         _position  = position;
         _positionX = x;
         _positionY = y;
     }
 }
        // Creates a native express ad view.
        public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position)
        {
            nativeExpressAdClientPtr = (IntPtr)GCHandle.Alloc(this);
            this.NativeExpressAdViewPtr = Externs.GADUCreateNativeExpressAdView(
                nativeExpressAdClientPtr, adUnitId, adSize.Width, adSize.Height, (int)position);

            Externs.GADUSetNativeExpressAdCallbacks(
                    this.NativeExpressAdViewPtr,
                    this.NativeExpressAdViewDidReceiveAdCallback,
                    this.NativeExpressAdViewDidFailToReceiveAdWithErrorCallback,
                    this.NativeExpressAdViewWillPresentScreenCallback,
                    this.NativeExpressAdViewDidDismissScreenCallback,
                    this.NativeExpressAdViewWillLeaveApplicationCallback);
        }
Ejemplo n.º 13
0
    public void RequestBanner(string adName, AdSize adSize, AdPosition adPosition)
    {
        AdxBannerRequest bannerAdsObject;

        if (_bannerAdsObjectDic.ContainsKey(adName))
        {
            bannerAdsObject = _bannerAdsObjectDic[adName];
        }
        else
        {
            GameObject gameObject = new GameObject("BannerAdsObject_" + adName);
            bannerAdsObject = gameObject.AddComponent <AdxBannerRequest>();
            _bannerAdsObjectDic.Add(adName, bannerAdsObject);
        }

        MoPub.AdPosition mAdPosition = MoPub.AdPosition.BottomCenter;
        switch (adPosition)
        {
        case AdPosition.Bottom:
            mAdPosition = MoPub.AdPosition.BottomCenter;
            break;

        case AdPosition.BottomLeft:
            mAdPosition = MoPub.AdPosition.BottomLeft;
            break;

        case AdPosition.BottomRight:
            mAdPosition = MoPub.AdPosition.BottomRight;
            break;

        case AdPosition.Center:
            mAdPosition = MoPub.AdPosition.Centered;
            break;

        case AdPosition.Top:
            mAdPosition = MoPub.AdPosition.TopCenter;
            break;

        case AdPosition.TopLeft:
            mAdPosition = MoPub.AdPosition.TopLeft;
            break;

        case AdPosition.TopRight:
            mAdPosition = MoPub.AdPosition.TopRight;
            break;
        }


        bannerAdsObject.RequestBanner(_adData.GetAdUnitId(AdType.BANNER, adName), mAdPosition);
    }
Ejemplo n.º 14
0
 private void RequestBannerAs(AdSize bannerSize, AdPosition bannerPosition)
 {
     if (bannerView != null)
     {
         bannerView.Destroy();
     }
     bannerView                         = new BannerView(_admob_Banner, bannerSize, bannerPosition);
     bannerView.OnAdLoaded             += HandleAdLoaded;
     bannerView.OnAdFailedToLoad       += HandleAdFailedToLoad;
     bannerView.OnAdOpening            += HandleAdOpened;
     bannerView.OnAdClosed             += HandleAdClosed;
     bannerView.OnAdLeavingApplication += HandleAdLeftApplication;
     bannerView.LoadAd(CreateAdRequest());
 }
Ejemplo n.º 15
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.CreateBanner(string,MoPubBase.AdPosition,MoPubBase.BannerType)"/>
    public static void CreateBanner(string adUnitId, AdPosition position, BannerType bannerType = BannerType.Size320x50)
    {
        MoPubLog.Log("CreateBanner", MoPubLog.AdLogEvent.LoadAttempted);
        MP plugin;

        if (PluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.CreateBanner(bannerType, position);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Ejemplo n.º 16
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.CreateBanner(string,MoPubBase.AdPosition,MoPubBase.BannerType)"/>
    public static void CreateBanner(string adUnitId, AdPosition position)
    {
        MoPubLog.Log("CreateBanner", MoPubLog.AdLogEvent.LoadAttempted);
        MPBanner plugin;

        if (BannerPluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.CreateBanner(position);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Ejemplo n.º 17
0
        public DataPager <AdPosition> GetAdPositionList(AdPosition model, int pageNo, int pageSize)
        {
            string        rowNumberOrderby = "AdPositionID asc";
            StringBuilder strWhere         = new StringBuilder("");

            strWhere.Append("1=1");

            var selectFields = "AdPositionID, Name, Sort, DefaultPicUrl, AdReleaseID, CreatUserID, RecordUpdateUserID, RecordIsDelete, RecordUpdateTime, RecordCreateTime ";
            var outFields    = "AdPositionID, Name, Sort, DefaultPicUrl, AdReleaseID, CreatUserID, RecordUpdateUserID, RecordIsDelete, RecordUpdateTime, RecordCreateTime ";
            var tableName    = @"AdPosition    ";
            var dataPager    = SqlDataUtilityHelper.GetDataToPager <AdPosition>(outFields, selectFields, tableName, rowNumberOrderby, this.ConnectionString, strWhere.ToString(), null, pageNo, pageSize);

            return(dataPager);
        }
Ejemplo n.º 18
0
 public BannerClient(string blockId, AdSize adSize, AdPosition position)
 {
     this.selfPointer = GCHandle.ToIntPtr(GCHandle.Alloc(this));
     this.ObjectId    = BannerBridge.YMAUnityCreateBannerView(
         this.selfPointer, blockId, adSize.Width, adSize.Height,
         (int)position);
     BannerBridge.YMAUnitySetBannerCallbacks(
         this.ObjectId,
         AdViewDidReceiveAdCallback,
         AdViewDidFailToReceiveAdWithErrorCallback,
         AdViewWillPresentScreenCallback,
         AdViewDidDismissScreenCallback,
         AdViewWillLeaveApplicationCallback);
 }
Ejemplo n.º 19
0
        private void SetAndStretchAd(GameObject dummyAd, AdPosition pos, AdSize adSize)
        {
            if (dummyAd != null)
            {
                Image         myImage = dummyAd.GetComponentInChildren <Image>();
                RectTransform rect    = myImage.GetComponentInChildren <RectTransform>();

                rect.pivot = new Vector2(0.5f, 0.5f);

                if (pos == AdPosition.Bottom || pos == AdPosition.BottomLeft || pos == AdPosition.BottomRight)
                {
                    rect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 0, rect.sizeDelta.y);
                    rect.anchoredPosition = new Vector2(0, (float)rect.sizeDelta.y / 2);
                }
                else if (pos == AdPosition.Top || pos == AdPosition.TopLeft || pos == AdPosition.TopRight)
                {
                    rect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, rect.sizeDelta.y);
                    rect.anchoredPosition = new Vector2(0, -(float)rect.sizeDelta.y / 2);
                }
                else if (pos == AdPosition.Center)
                {
                    LoadAndSetPrefabAd("DummyAds/Banners/CENTER");
                    if (adSize.AdType == AdSize.Type.AnchoredAdaptive)
                    {
                        LoadAndSetPrefabAd("DummyAds/Banners/CENTER");
                        Text adText = prefabAd.GetComponentInChildren <Image>().GetComponentInChildren <Text>();
                        adText.text = "This is a Test Adaptive Banner";
                    }
                    else if (adSize == AdSize.SmartBanner)
                    {
                        LoadAndSetPrefabAd("DummyAds/Banners/CENTER");
                        Text adText = prefabAd.GetComponentInChildren <Image>().GetComponentInChildren <Text>();
                        adText.text = "This is a Test Smart Banner";
                    }
                    else
                    {
                        rect.anchoredPosition = new Vector2(0, 0);
                    }
                }
                else
                {
                    rect.anchoredPosition = rect.position;
                }
            }
            else
            {
                // Debug.Log("Invalid Dummy Ad");
            }
        }
        /// <summary>
        /// Show a banner.
        /// </summary>
        public void ShowBanner(string adUnitId = null, AdSize size = null, AdPosition position = AdPosition.Bottom, Action onLoadedCallback = null, Action onFailedToLoadCallback = null, Action onOpeningCallback = null, Action onClosedCallback = null)
        {
            if (adUnitId == null)
            {
#if UNITY_ANDROID
                adUnitId = PlayerPrefs.GetString("MyAdMobManager_BannerId", mAndroidDefaultBannerId);
#elif UNITY_IOS
                adUnitId = PlayerPrefs.GetString("MyAdMobManager_BannerId", mIosDefaultBannerId);
#endif
            }

            if (size == null)
            {
                size = AdSize.Banner;
            }

#if DEBUG_MY_ADMOB
            Debug.Log("[" + typeof(MyAdMobManager).Name + "] ShowBanner(): adUnitId=" + adUnitId + " | size=" + size.AdType + " | position=" + position);
#endif

            mOnBannerLoadedCallback       = onLoadedCallback;
            mOnBannerFailedToLoadCallback = onFailedToLoadCallback;
            mOnBannerOpeningCallback      = onOpeningCallback;
            mOnBannerClosedCallback       = onClosedCallback;

            mCountBannerRequest += 1;

            mLastBannerRequestTimestamp = MyLocalTime.CurrentUnixTime;
#if UNITY_EDITOR
            mLastBannerShowTimestamp = MyLocalTime.CurrentUnixTime;
#else
            mIsLoadingBanner = true;
#endif

            if (mBannerRequest == null)
            {
                mBannerRequest = new AdRequest.Builder().Build();
            }
            if (mBanner != null)
            {
                mBanner.Destroy();
            }
            mBanner = new BannerView(adUnitId, size, position);
            mBanner.LoadAd(mBannerRequest);
            mBanner.OnAdLoaded       += _OnBannerLoaded;
            mBanner.OnAdFailedToLoad += _OnBannerFaiedToLoad;
            mBanner.OnAdOpening      += _OnBannerOpening;
            mBanner.OnAdClosed       += _OnBannerClosed;
        }
    public void RequestBanner(AdPosition position, String id)

    {
        bannerAndroidid = id;
        this.bannerView = new BannerView(bannerAndroidid, AdSize.SmartBanner, position);

        this.bannerView.OnAdLoaded             += this.HandleAdLoaded;
        this.bannerView.OnAdFailedToLoad       += this.HandleAdFailedToLoad;
        this.bannerView.OnAdOpening            += this.HandleAdOpened;
        this.bannerView.OnAdClosed             += this.HandleAdClosed;
        this.bannerView.OnAdLeavingApplication += this.HandleAdLeftApplication;

        // Load a banner ad.
        this.bannerView.LoadAd(this.CreateAdRequest());
    }
Ejemplo n.º 22
0
    public override void RequestAd(AdPosition positionOnScreen = AdPosition.Bottom)
    {
        // Create a 320x50 banner at the top of the screen.
        this.bannerView = new BannerView(componentTypeStringAdmob, AdSize.Banner, positionOnScreen);

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();

        // Load the banner with the request.
        this.bannerView.LoadAd(request);

        base.RequestAd(positionOnScreen);

        Destroy(this.gameObject, 5.3f);
    }
Ejemplo n.º 23
0
    public void FetechBannerAds(AdsType type, AdSize size)
    {
        if (adsType == AdsType.BannerBottom)
        {
            position = AdPosition.Bottom;
        }
        else if (adsType == AdsType.BannerTop)
        {
            position = AdPosition.Top;
        }
        else
        {
            position = AdPosition.Bottom;
        }

        if (size == AdSize.Banner)
        {
            adSize = AdSize.Banner;
        }
        else if (size == AdSize.SmartBanner)
        {
            adSize = AdSize.SmartBanner;
        }
        else
        {
            adSize = AdSize.Banner;
        }

        bannerAds = new BannerView(AdsConfig.AdsAdmobBannerPlacement, size, position);

        if (bannerAds != null)
        {
            AdRequest request = new AdRequest.Builder().AddTestDevice("063215AC51C16009CE71243D30B7C2A1").Build();

            bannerAds.LoadAd(request);

            bannerAds.AdLoaded          += BannerAds_AdLoaded;
            bannerAds.AdFailedToLoad    += BannerAds_AdFailedToLoad;
            bannerAds.AdOpened          += BannerAds_AdOpened;
            bannerAds.AdClosing         += BannerAds_AdClosing;
            bannerAds.AdClosed          += BannerAds_AdClosed;
            bannerAds.AdLeftApplication += BannerAds_AdLeftApplication;
        }
        else
        {
            Debug.LogError("AdsManger: Banner Ads isn't, please init it");
        }
    }
Ejemplo n.º 24
0
        static string GetBanner(AdPosition position)
        {
            if (EaAd.isSingleBanner)
            {
                return(EaAd.banner);
            }

            switch (position)
            {
            case AdPosition.Top:
                return(EaAd.bannerTop);

            default:
                return(EaAd.bannerBottom);
            }
        }
Ejemplo n.º 25
0
        public bool Show(AdPosition position)
        {
            double y = 0.0;

            switch (position)
            {
            case AdPosition.BOTTOM:
                y = AdUtility.height() - heightFromType(size);
                break;

            case AdPosition.CUSTOM:
                UnityEngine.Debug.LogWarning("Use Show(double y) instead");
                break;
            }
            return(Show(y));
        }
        public void RequestAdView(string zoneId, AdSize adSize, AdPosition adPosition, AdOptions adOptions)
        {
            Hashtable values = new Hashtable();

            values["zone_id"]     = zoneId;
            values["ad_size"]     = (Int32)adSize;
            values["ad_position"] = (Int32)adPosition;
            if (adOptions != null)
            {
                values["ad_options"] = adOptions.ToHashtable();
            }

            string json = AdColonyJson.Encode(values);

            _pluginWrapper.CallStatic("requestAdView", json);
        }
Ejemplo n.º 27
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.RequestBanner(string,MoPub.AdPosition,MoPub.MaxAdSize)"/>
    public static void RequestBanner(string adUnitId, AdPosition position,
                                     MaxAdSize maxAdSize = MaxAdSize.Width320Height50)
    {
        MoPubLog.Log("RequestBanner", MoPubLog.AdLogEvent.LoadAttempted);
        MoPubLog.Log("RequestBanner", "Size requested: " + maxAdSize.Width() + "x" + maxAdSize.Height());
        MPBanner plugin;

        if (BannerPluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.RequestBanner(maxAdSize.Width(), maxAdSize.Height(), position);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Ejemplo n.º 28
0
 private void RequestBanner(string adUnitId, AdSize adSize, AdPosition position = AdPosition.Bottom)
 {
     // Create a 320x50 banner at the top of the screen.
     if (!this.bannerViews.ContainsKey(adUnitId))
     {
         this.bannerViews.Add(adUnitId, new BannerView(adUnitId, adSize, position));
         // Register for ad events.
         this.bannerViews[adUnitId].OnAdLoaded             += this.HandleOnBannerAdLoaded;
         this.bannerViews[adUnitId].OnAdFailedToLoad       += this.HandleOnBannerAdFailedToLoad;
         this.bannerViews[adUnitId].OnAdOpening            += this.HandleOnBannerAdOpening;
         this.bannerViews[adUnitId].OnAdClosed             += this.HandleOnBannerAdClosed;
         this.bannerViews[adUnitId].OnAdLeavingApplication += this.HandleOnBannerAdLeftApplication;
     }
     // Load a banner ad.
     this.bannerViews[adUnitId].LoadAd(this.CreateAdRequest());
 }
Ejemplo n.º 29
0
    public void RequestNativeExpress(string adUnitId, AdSize size, AdPosition position)
    {
#if ADMOB
        MyDebug.Log(string.Format("GMAS::RequestNativeExpress => Request Start for: {0}", adUnitId));
        if (!this.nativeAdViews.ContainsKey(adUnitId))
        {
            // Create an this.interstitial.
            this.nativeAdViews.Add(adUnitId, new NativeExpressAdView(adUnitId, size, position));
            this.BindNLoadNativeExpressAdView(adUnitId);
        }
        else
        {
            MyDebug.Log(string.Format("GMAS::RequestNativeExpress => adUnitId: {0} already requested", adUnitId));
        }
#endif
    }
Ejemplo n.º 30
0
    public void RequestBanner(AdPosition position)
    {
        if (position == null)
        {
            position = AdPosition.Top;
        }
//
//		// Create a 320x50 banner at the top of the screen.
        banner = new BannerView(Constants.AndroidHouseAdID, AdSize.Banner, position);
//		// Create an empty ad request.
        adRequester = new AdRequest.Builder().
                      Build();

//		// Load the banner with the request.
        banner.LoadAd(adRequester);
    }
Ejemplo n.º 31
0
        // Creates a NativeExpressAd and adds it to the view hierarchy.
        public NativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position)
        {
            this.client = GoogleMobileAdsClientFactory.BuildNativeExpressAdClient();
            this.client.CreateNativeExpressAdView(adUnitId, adSize, position);

            this.client.OnAdLoaded += (sender, args) => this.OnAdLoaded(this, args);

            this.client.OnAdFailedToLoad += (sender, args) => this.OnAdFailedToLoad(this, args);

            this.client.OnAdOpening += (sender, args) => this.OnAdOpening(this, args);

            this.client.OnAdClosed += (sender, args) => this.OnAdClosed(this, args);

            this.client.OnAdLeavingApplication += (sender, args) =>
                                                  this.OnAdLeavingApplication(this, args);
        }
 // Creates a banner view and adds it to the view hierarchy.
 public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name);
     LoadAndSetPrefabAd(prefabAds[adSize]);
     if (prefabAd != null)
     {
         if (adSize == AdSize.SmartBanner)
         {
             SetAndStretchAd(prefabAd, position);
         }
         else
         {
             AnchorAd(prefabAd, position);
         }
     }
 }
    public void LoadBanner()
    {
        if (adView)
        {
            adView.Dispose();
        }

        statusLabel.text = "Loading Banner...";

        // Create a banner's ad view with a unique placement ID
        // (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        adView = new AdView("YOUR_PLACEMENT_ID", adSizeArray[currentAdSize]);


        adView.Register(gameObject);
        currentAdViewPosition = AdPosition.CUSTOM;

        // Set delegates to get notified on changes or when the user interacts
        // with the ad.
        adView.AdViewDidLoad = delegate()
        {
            currentScreenOrientation = Screen.orientation;
            adView.Show(100);
            string isAdValid = adView.IsValid() ? "valid" : "invalid";
            statusLabel.text = "Banner loaded and is " + isAdValid + ".";
            Debug.Log("Banner loaded");
        };
        adView.AdViewDidFailWithError = delegate(string error)
        {
            statusLabel.text = "Banner failed to load with error: " + error;
            Debug.Log("Banner failed to load with error: " + error);
        };
        adView.AdViewWillLogImpression = delegate()
        {
            statusLabel.text = "Banner logged impression.";
            Debug.Log("Banner logged impression.");
        };
        adView.AdViewDidClick = delegate()
        {
            statusLabel.text = "Banner clicked.";
            Debug.Log("Banner clicked.");
        };

        // Initiate a request to load an ad.
        adView.LoadAd();
    }
Ejemplo n.º 34
0
        // Creates a banner view.
        public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position) {
            IntPtr bannerClientPtr = (IntPtr) GCHandle.Alloc(this);

            if (adSize.IsSmartBanner) {
                BannerViewPtr = Externs.GADUCreateSmartBannerView(
                        bannerClientPtr, adUnitId, (int)position);
            }
            else
            {
                BannerViewPtr = Externs.GADUCreateBannerView(
                        bannerClientPtr, adUnitId, adSize.Width, adSize.Height, (int)position);
            }
            Externs.GADUSetBannerCallbacks(
                    BannerViewPtr,
                    AdViewDidReceiveAdCallback,
                    AdViewDidFailToReceiveAdWithErrorCallback,
                    AdViewWillPresentScreenCallback,                    
                    AdViewDidDismissScreenCallback,
                    AdViewWillLeaveApplicationCallback);
        }
Ejemplo n.º 35
0
        void UpdateAd(bool isEnabled, AdPosition position, AdSize size, SlidingAdDirection slidingDirection, int slidingAdDisplaySeconds, int slidingAdHiddenSeconds)
        {
            var ads = GameObject.Find("AdRotatorManagement");
            if (ads != null)
            {
                var adMgt = ads.GetComponent<AdRotatorManagement>();

                adMgt.AdSettings.IsEnabled = false;
                adMgt.AdSettings.Position = AdPosition.TopCenter;
                adMgt.AdSettings.IsEnabled = isEnabled;
                adMgt.AdSettings.Position = position;
                adMgt.AdSettings.Size = size;
                adMgt.AdSettings.SlidingAdDirection = slidingDirection;
                adMgt.AdSettings.SlidingAdDisplaySeconds = slidingAdDisplaySeconds;
                adMgt.AdSettings.SlidingAdHiddenSeconds = slidingAdHiddenSeconds;
                adMgt.UpdateAd();
            }
            else
            {
                Debug.LogError("AdRotatorManagement game object cannot be found.");
            }
        }
Ejemplo n.º 36
0
    public void RequestBanner(AdPosition position = AdPosition.Bottom)
    {
        #if UNITY_EDITOR
        string adUnitId = "unused";
        #elif UNITY_ANDROID
            string adUnitId = adUnitIdAndroidBanner;
        #elif UNITY_IPHONE
            string adUnitId = adUnitIdIOSBanner;
        #else
            string adUnitId = "unexpected_platform";
        #endif

        // Create a 320x50 banner at the top of the screen.
        bannerView = new BannerView(adUnitId, AdSize.SmartBanner, position);
        // Register for ad events.
        bannerView.AdLoaded += HandleAdLoaded;
        bannerView.AdFailedToLoad += HandleAdFailedToLoad;
        bannerView.AdOpened += HandleAdOpened;
        bannerView.AdClosing += HandleAdClosing;
        bannerView.AdClosed += HandleAdClosed;
        bannerView.AdLeftApplication += HandleAdLeftApplication;
        // Load a banner ad.
        bannerView.LoadAd(createAdRequest());
    }
Ejemplo n.º 37
0
		// Create a BannerView and add it into the view hierarchy.
		public BannerView(string adUnitId, AdPosition position)
		{
			client = AdcashClientFactory.GetAdcashBannerClient(this);
			client.CreateBannerView(adUnitId, position);
		}
 // Creates a banner view.
 public void CreateBannerView(String adUnitId, AdSize adSize, AdPosition position) {
     bannerView.Call("create",
             new object[3] { adUnitId, Utils.GetAdSizeJavaObject(adSize), (int)position });
 }
Ejemplo n.º 39
0
 public void CreateBannerView(string adUnitId, AdPosition position)
 {
     Console.WriteLine("Dummy CreateBannerView");
 }
Ejemplo n.º 40
0
 public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name);
 }
 public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     Debug.Log("Dummy CreateBannerView");
 }
 // Creates a native express ad view.
 public void CreateNativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position)
 {
     this.nativeExpressAdView.Call(
             "create",
             new object[3] { adUnitId, Utils.GetAdSizeJavaObject(adSize), (int)position });
 }
Ejemplo n.º 43
0
 public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
 }
Ejemplo n.º 44
0
 // Create a BannerView and add it into the view hierarchy.
 public BannerView(string adUnitId, AdSize adSize, AdPosition position)
 {
     client = GoogleMobileAdsClientFactory.GetGoogleMobileAdsBannerClient(this);
     client.CreateBannerView(adUnitId, adSize, position);
 }
Ejemplo n.º 45
0
 // Creates a banner view.
 public void CreateBannerView(String adUnitId, AdPosition position)
 {
     bannerView.Call("create",
                     new object[2] { adUnitId, (int)position });
 }
Ejemplo n.º 46
0
 /// <summary>
 /// Initializes a new instance of AdSettings.
 /// </summary>
 /// <param name="src">Settings to clone.</param>
 public AdSettings(AdSettings src)
 {
     this.IsEnabled = src.IsEnabled;
     this.Position = src.Position;
     this.Size = src.Size;
     this.SlidingAdDirection = src.SlidingAdDirection;
     this.SlidingAdDisplaySeconds = src.SlidingAdDisplaySeconds;
     this.SlidingAdHiddenSeconds = src.SlidingAdHiddenSeconds;
 }
Ejemplo n.º 47
0
    /**
     * wyświetlenie banera
     */
    public void StartBanner(AdPosition position)
    {
        #if SIMULATOR
        return;
        #endif
        #if UNITY_ANDROID || UNITY_IPHONE
        bannerView = new BannerView(adUnitId, AdSize.SmartBanner,position);
        bannerView.AdLoaded += HandleAdLoaded;
        bannerView.AdFailedToLoad += HandleAdFailedToLoad;
        bannerView.AdOpened += HandleAdOpened;
        bannerView.AdClosing += HandleAdClosing;
        bannerView.AdClosed += HandleAdClosed;
        bannerView.AdLeftApplication += HandleAdLeftApplication;

        bannerView.LoadAd(createAdRequest());
        #endif
    }
Ejemplo n.º 48
0
	public static void ShowBanner(AdSize adSize, AdPosition adPosition)
	{
		Debug.Log("Show Banner Ad");
		#if ADMOB_IMPLEMENTED
		//if we already created it we could just show it
		if(bannerView != null)
			bannerView.Show();
		else//create a new one
		{
			_adSize = adSize;
			_adPosition = adPosition;

			CreateBannerRequest();
		}

		#endif
	}
Ejemplo n.º 49
0
 /// <summary>
 /// Initializes a new instance of AdSettings.
 /// </summary>
 public AdSettings()
 {
     this.IsEnabled = true;
     this.Position = AdPosition.TopCenter;
     this.Size = AdSize.Leaderboard728x90;
     this.SlidingAdDirection = SlidingAdDirection.None;
     this.SlidingAdDisplaySeconds = 0;
     this.SlidingAdHiddenSeconds = 0;
 }