示例#1
0
    private void Update()
    {
        NativeAd nativeAd = this.adManager.nativeAd;

        if (this.adManager.IsAdLoaded() && (nativeAd != null))
        {
            if ((nativeAd.CoverImage != null) && !this.adCoverContentFilled)
            {
                this.adCoverContentFilled = true;
                this.coverImage.set_sprite(nativeAd.CoverImage);
            }
            if ((nativeAd.IconImage != null) && !this.adIconContentFilled)
            {
                this.adIconContentFilled = true;
                this.iconImage.set_sprite(nativeAd.IconImage);
            }
            if (!this.adTextContentFilled)
            {
                this.adTextContentFilled = true;
                this.title.text          = nativeAd.Title;
                this.socialContext.text  = nativeAd.SocialContext;
                this.callToAction.text   = nativeAd.CallToAction;
            }
        }
    }
示例#2
0
        public static void InitNative(Activity activity, LinearLayout nativeAdLayout, NativeAd ad)
        {
            try
            {
                if (AppSettings.ShowFbNativeAds)
                {
                    InitializeFacebook.Initialize(activity);

                    if (ad == null)
                    {
                        var nativeAd = new NativeAd(activity, AppSettings.AdsFbNativeKey);
#pragma warning disable 618
                        nativeAd.SetAdListener(new NativeAdListener(activity, nativeAd, nativeAdLayout));
#pragma warning restore 618

                        // Initiate a request to load an ad.
                        nativeAd.LoadAd();
                    }
                    else
                    {
                        var holder = new AdHolder(nativeAdLayout);
                        LoadAd(activity, holder, ad, nativeAdLayout);
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        public void LoadAd()
        {
            // Giới hạn thời gian giữa 2 lần gửi request
            var now = DateTime.Now;

            if (now.Subtract(lastTimeSentRequest).TotalSeconds < AdUnit.minSecondsToReload)
            {
                return;
            }
            lastTimeSentRequest = now;
            //CLog.Log("[FBAD]Loading ads " + AdUnit.name);
            IsLoaded      = false;
            didLoadedData = false;

            if (!AdsMaster.SupportedAdPlatform)
            {
                return;
            }
            // Create a native ad request with a unique placement ID (generate your own on the Facebook app settings).
            // Use different ID for each ad placement in your app.
            NativeAd = new AudienceNetwork.NativeAd(AdUnit.PlacementId);

            // Wire up GameObject with the native ad; the specified buttons will be clickable.
            NativeAd.RegisterGameObjectForImpression(gameObject, new Button[] { });

            // Set delegates to get notified on changes or when the user interacts with the ad.
            NativeAd.NativeAdDidLoad           = HandleAdDidLoad;
            NativeAd.NativeAdDidFailWithError  = HandleAdDidFailWithError;
            NativeAd.NativeAdWillLogImpression = HandleAdWillLogImpression;
            NativeAd.NativeAdDidClick          = HandleAdDidClick;

            // Initiate a request to load an ad.
            NativeAd.LoadAd();
        }
示例#4
0
            private void InflateAd(NativeAd nativeAd, View adView)
            {
                try
                {
                    // Create native UI using the ad metadata.
                    var holder = new AdHolder(adView);
                    NativeAdChoicesContainer = holder.NativeAdChoicesContainer;

                    // Setting the Text
                    holder.NativeAdSocialContext.Text      = nativeAd.AdSocialContext;
                    holder.NativeAdCallToAction.Text       = nativeAd.AdCallToAction;
                    holder.NativeAdCallToAction.Visibility = nativeAd.HasCallToAction ? ViewStates.Visible : ViewStates.Invisible;
                    holder.NativeAdTitle.Text  = nativeAd.AdvertiserName;
                    holder.NativeAdBody.Text   = nativeAd.AdBodyText;
                    holder.SponsoredLabel.Text = Activity.GetText(Resource.String.sponsored);

                    // You can use the following to specify the clickable areas.
                    List <View> clickableViews = new List <View> {
                        holder.NativeAdIcon, holder.NativeAdMedia, holder.NativeAdCallToAction
                    };

                    nativeAd.RegisterViewForInteraction(NativeAdLayout, holder.NativeAdMedia, holder.NativeAdIcon, clickableViews);

                    // Optional: tag views
                    NativeAdBase.NativeComponentTag.TagView(holder.NativeAdIcon, NativeAdBase.NativeComponentTag.AdIcon);
                    NativeAdBase.NativeComponentTag.TagView(holder.NativeAdTitle, NativeAdBase.NativeComponentTag.AdTitle);
                    NativeAdBase.NativeComponentTag.TagView(holder.NativeAdBody, NativeAdBase.NativeComponentTag.AdBody);
                    NativeAdBase.NativeComponentTag.TagView(holder.NativeAdSocialContext, NativeAdBase.NativeComponentTag.AdSocialContext);
                    NativeAdBase.NativeComponentTag.TagView(holder.NativeAdCallToAction, NativeAdBase.NativeComponentTag.AdCallToAction);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
示例#5
0
    private void OnGUI()
    {
        NativeAd nativeAd = adManager.nativeAd;

        if ((bool)nativeAd && adManager.IsAdLoaded() && !adRendered)
        {
            Sprite sprite = null;
            if (useCoverImage)
            {
                sprite = nativeAd.CoverImage;
            }
            else if (useIconImage)
            {
                sprite = nativeAd.IconImage;
            }
            if ((bool)sprite)
            {
                MeshRenderer component  = GetComponent <MeshRenderer>();
                Renderer     component2 = GetComponent <Renderer>();
                component2.enabled = true;
                Texture2D texture  = sprite.texture;
                Material  material = new Material(Shader.Find("Sprites/Default"));
                material.color = Color.white;
                material.SetTexture("texture", texture);
                component.sharedMaterial        = material;
                component2.material.mainTexture = texture;
                adRendered = true;
            }
        }
    }
示例#6
0
    void Update()
    {
        NativeAd nativeAd = adManager.nativeAd;

        if (adManager.IsAdLoaded() && nativeAd != null)
        {
            // Update GUI from native ad
            if (nativeAd.CoverImage != null && !adCoverContentFilled)
            {
                adCoverContentFilled = true;
                coverImage.sprite    = nativeAd.CoverImage;
            }
            if (nativeAd.IconImage != null && !adIconContentFilled)
            {
                adIconContentFilled = true;
                iconImage.sprite    = nativeAd.IconImage;
            }

            if (!adTextContentFilled)
            {
                adTextContentFilled = true;
                title.text          = nativeAd.Title;
                socialContext.text  = nativeAd.SocialContext;
                callToAction.text   = nativeAd.CallToAction;
            }
        }
    }
示例#7
0
#pragma warning disable 162
    public void LoadNativeAds(string placementID)
    {
#if UNITY_ANDROID || UNITY_IPHONE
        if (impressionCamera == null)
        {
            Debug.LogWarning("Impression camera for native ads is null, no native ads will be created");
            return;
        }

#if UNITY_EDITOR
        //#if UNITY_ANDROID
        //        //only run on device
        //
        //#elif UNITY_IOS

        //#endif
        //#else
        return;
#endif

        //AdSettings.AddTestDevice("4b55fbfb8fb5b2f91ef8ac3a2d44fd9e");
        // Create a native ad request with a unique placement ID (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        NativeAd nativeAd = new AudienceNetwork.NativeAd(placementID);
        this.nativeAd = nativeAd;
        //print("Loading native ads with ID " + placementID);
        nativeAd.RegisterGameObjectForImpression(gameObject, new UIButton[] { btnCall2Action }, impressionCamera);
        nativeAd.NativeAdDidLoad           = OnNativeAdLoaded;
        nativeAd.NativeAdDidFailWithError  = OnNativeAdLoadFailed;
        nativeAd.NativeAdWillLogImpression = OnNativeAdWillLogImpression;
        nativeAd.NativeAdDidClick          = OnNativeAdClicked;
        nativeAd.LoadAd();


        //// Set delegates to get notified on changes or when the user interacts with the ad.
        //nativeAd.NativeAdDidLoad = (delegate () {
        //    print("+++++++++======Native ad loaded.");
        //    Debug.Log("Loading images...");
        //    // Use helper methods to load images from native ad URLs
        //    StartCoroutine(nativeAd.LoadIconImage(nativeAd.IconImageURL));
        //    StartCoroutine(nativeAd.LoadCoverImage(nativeAd.CoverImageURL));
        //    Debug.Log("Images loaded.");
        //    txtTitle.text = nativeAd.Title;
        //    txtSocialContext.text = nativeAd.SocialContext;
        //    txtCall2Action.text = nativeAd.CallToAction;
        //});
        //nativeAd.NativeAdDidFailWithError = (delegate (string error) {
        //    print("++++++=====Native ad failed to load with error: " + error);
        //});
        //nativeAd.NativeAdWillLogImpression = (delegate () {
        //    print("++++++++=====Native ad logged impression.");
        //});
        //nativeAd.NativeAdDidClick = (delegate () {
        //    print("+++++++=====Native ad clicked.");
        //});


        Debug.Log("=====+++++++LOADING NATIVE ADS with ID " + placementID);
#endif
    }
        public void NativeAdDidLoad(NativeAd nativeAd)
        {
            CustomNativeAd customNativeAd;

            lock (padlock) {
                customNativeAd = new CustomNativeAd(nativeAd, nativeAdTemplate == nativeAd);
                customNativeAds.Add(customNativeAd);
            }

            InsertRow();

            //if (!customNativeAd.IsTemplate) {

            //	return;
            //}

            //// Native Ad Template Logic
            //var nativeAdView = NativeAdView.From (nativeAd, NativeAdViewType.GenericHeight300);
            //customNativeAds.Add (nativeAdView);

            //// Register the native ad view and its view controller with the native ad instance
            //nativeAd.RegisterView (nativeAdView, this);

            //var newIndexPath = NSIndexPath.FromRowSection (customNativeAds.Count - 1, 0);
            //AdsTableView.InsertRows (new [] { newIndexPath }, UITableViewRowAnimation.Automatic);
            //AdsTableView.ScrollToRow (newIndexPath, UITableViewScrollPosition.Bottom, true);
        }
示例#9
0
        public void OnNativeAdLoad(AndroidJavaObject list, NativeAd ad)
        {
#if UNITY_IOS
            this.example.bannerAd        = ad;
            this.example.intersititialAd = ad;
            ad.SetNativeAdInteractionListener(
                new NativeAdInteractionListener(this.example)
                );
#else
            var size = list.Call <int>("size");

            if (size > 0)
            {
                this.example.mBannerAd        = list.Call <AndroidJavaObject>("get", 0);
                this.example.mIntersititialAd = list.Call <AndroidJavaObject>("get", 0);
            }
#endif
            //if (ads == null && ads.[0])
            //{
            //    return;
            //}
            ////this.example.bannerAd = ads.[0];
            //this.example.bannerAd = ads.[0];
            Debug.Log("OnNativeAdLoad");
            this.example.information.text = "OnNativeAdLoad";


            //bannerAd.;
            //bannerAd.SetDownloadListener(
            //new AppDownloadListener(this.example));
        }
示例#10
0
 public static void InitNative(Activity activity, NativeAdLayout nativeAdLayout, NativeAd ad)
 {
     try
     {
         var isPro = ListUtils.MyUserInfoList.FirstOrDefault()?.IsPro ?? 0;
         if (isPro == 0 && AppSettings.ShowFbNativeAds)
         {
             if (ad == null)
             {
                 var nativeAd = new NativeAd(activity, AppSettings.AdsFbNativeKey);
                 nativeAd.SetAdListener(new NativeAdListener(activity, nativeAd, nativeAdLayout));
                 // Initiate a request to load an ad.
                 nativeAd.LoadAd();
             }
             else
             {
                 var holder = new AdHolder(nativeAdLayout);
                 LoadAd(activity, holder, ad, nativeAdLayout);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
示例#11
0
    private void OnGUI()
    {
        NativeAd nativeAd = this.adManager.nativeAd;

        if (((nativeAd != null) && this.adManager.IsAdLoaded()) && !this.adRendered)
        {
            Sprite coverImage = null;
            if (this.useCoverImage)
            {
                coverImage = nativeAd.CoverImage;
            }
            else if (this.useIconImage)
            {
                coverImage = nativeAd.IconImage;
            }
            if (coverImage != null)
            {
                MeshRenderer component = base.GetComponent <MeshRenderer>();
                Renderer     renderer2 = base.GetComponent <Renderer>();
                renderer2.enabled = true;
                Texture2D texture  = coverImage.texture;
                Material  material = new Material(Shader.Find("Sprites/Default"))
                {
                    color = Color.white
                };
                material.SetTexture("texture", texture);
                component.sharedMaterial       = material;
                renderer2.material.mainTexture = texture;
                this.adRendered = true;
            }
        }
    }
示例#12
0
 public static void InitNative(Activity activity, NativeAdLayout nativeAdLayout, NativeAd ad)
 {
     try
     {
         if (AppSettings.ShowFbNativeAds)
         {
             if (ad == null)
             {
                 var nativeAd = new NativeAd(activity, AppSettings.AdsFbNativeKey);
                 nativeAd.SetAdListener(new NativeAdListener(activity, nativeAd, nativeAdLayout));
                 // Initiate a request to load an ad.
                 nativeAd.LoadAd();
             }
             else
             {
                 var holder = new AdHolder(nativeAdLayout);
                 LoadAd(activity, holder, ad, nativeAdLayout);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
 void AddNativeAdTemplate(UIAlertAction obj)
 {
     nativeAdTemplate = new NativeAd(AdPlacementIds.Native)
     {
         Delegate = this
     };
     nativeAdTemplate.LoadAd();
 }
示例#14
0
 void AddNativeAd(UIAlertAction obj)
 {
     nativeAd = new NativeAd(AdPlacementIds.Native)
     {
         Delegate = this
     };
     nativeAd.MediaCachePolicy = NativeAdsCachePolicy.All;
     nativeAd.LoadAd();
 }
    protected override void OptionalInit()
    {
        // Create a native ad request with a unique placement ID (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        _nativeAd = new NativeAd(AdUnitId);

        // Wire up GameObject with the native ad; the specified buttons will be clickable.
        _nativeAd.RegisterGameObjectForImpression(gameObject, new Button[] { });
    }
        void showNativeAd()
        {
            var placementId = Resources.GetString(Resource.String.fb_placement_id);

            nativeAd = new NativeAd(this, placementId);
            nativeAd.SetAdListener(this);

            nativeAd.LoadAd();
        }
        /// <summary>
        /// Báo cho view là ad đã được cập nhật
        /// </summary>
        public static void OnLoadedAd(string adName, NativeAd ad)
        {
            FbNativeAdView view = null;

            if (!adViews.TryGetValue(adName, out view))
            {
                return;
            }
            view.OnUpdateAd(ad);
        }
示例#18
0
 public NativeAdInfo(NativeAd ad)
 {
     Native     = ad;
     Headline   = ad.Headline.OrEmpty();
     Advertiser = ad.AdvertiserName.OrEmpty();
     Body       = ad.BodyText.OrEmpty();
     //Icon = ConvertUIImageToByteArray(ad.AdChoicesIcon);
     SocialContext = ad.SocialContext.OrEmpty();
     CallToAction  = ad.CallToAction.OrEmpty();
 }
示例#19
0
    public void registerGameObjectForImpression()
    {
        NativeAd nativeAd = this.adManager.nativeAd;

        if ((nativeAd != null) && (base.gameObject.GetComponent <NativeAdHandler>() == null))
        {
            Button[] clickableButtons = new Button[] { this.callToActionButton };
            nativeAd.RegisterGameObjectForImpression(base.gameObject, clickableButtons);
        }
    }
示例#20
0
    public void registerGameObjectForImpression()
    {
        NativeAd nativeAd = adManager.nativeAd;

        if (nativeAd != null && gameObject.GetComponent <NativeAdHandler> () == null)
        {
            // Wire up GameObject with the native ad; the specified buttons will be clickable
            // if the ad panel is not registed with native ad
            nativeAd.RegisterGameObjectForImpression(gameObject, new Button[] { callToActionButton });
        }
    }
示例#21
0
    public void registerGameObjectForImpression()
    {
        NativeAd nativeAd = adManager.nativeAd;

        if (nativeAd != null && base.gameObject.GetComponent <NativeAdHandler>() == null)
        {
            nativeAd.RegisterGameObjectForImpression(base.gameObject, new Button[1]
            {
                callToActionButton
            });
        }
    }
示例#22
0
        public void OnNativeAdLoaded(NativeAd nativeAd)
        {
            Log.Info(TAG, "OnNativeAdLoaded");
            // Call this method when an ad is successfully loaded.
            UpdateStatus(GetString(Resource.String.status_load_ad_success), true);

            // Display native ad.
            ShowNativeAd(nativeAd);
            nativeAd.SetAllowCustomClick();
            Log.Info(TAG, "Called SetAllowCustomClick successfully.");
            nativeAd.SetDislikeAdListener(this);
        }
示例#23
0
    // Load Ad button
    public void LoadAd()
    {
        // Create a native ad request with a unique placement ID (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        NativeAd nativeAd = new AudienceNetwork.NativeAd("YOUR_PLACEMENT_ID");

        this.nativeAd = nativeAd;

        // Wire up GameObject with the native ad; the specified buttons will be clickable.
        if (targetAdObject)
        {
            if (targetButton)
            {
                nativeAd.RegisterGameObjectForImpression(targetAdObject, new Button[] { targetButton });
            }
            else
            {
                nativeAd.RegisterGameObjectForImpression(targetAdObject, new Button[] { });
            }
        }
        else
        {
            nativeAd.RegisterGameObjectForImpression(gameObject, new Button[] { });
        }

        // Set delegates to get notified on changes or when the user interacts with the ad.
        nativeAd.NativeAdDidLoad = (delegate() {
            adLoaded = true;
            Debug.Log("Native ad loaded.");
            Debug.Log("Loading images...");
            // Use helper methods to load images from native ad URLs
            StartCoroutine(nativeAd.LoadCoverImage(nativeAd.CoverImageURL));
            StartCoroutine(nativeAd.LoadIconImage(nativeAd.IconImageURL));
            Debug.Log("Images loaded.");
        });
        nativeAd.NativeAdDidFailWithError = (delegate(string error) {
            Debug.Log("Native ad failed to load with error: " + error);
        });
        nativeAd.NativeAdWillLogImpression = (delegate() {
            Debug.Log("Native ad logged impression.");
        });
        nativeAd.NativeAdDidClick = (delegate() {
            Debug.Log("Native ad clicked.");
        });

        // Initiate a request to load an ad.
        nativeAd.LoadAd();

        Debug.Log("Native ad loading...");
    }
        public void OnAdLoaded(IAd ad)
        {
            Android.Util.Log.Debug(TAG, "Native Ad Loaded");

            if (ad != nativeAd)
            {
                return;
            }

            // Add ad into the ad container.
            nativeAdContainer = FindViewById <LinearLayout> (Resource.Id.native_ad_container);

            var inflater = LayoutInflater.From(this);

            adView = (LinearLayout)inflater.Inflate(Resource.Layout.NativeAdView, nativeAdContainer, false);
            nativeAdContainer.AddView(adView);

            // Create native UI using the ad metadata.
            var nativeAdIcon          = adView.FindViewById <ImageView> (Resource.Id.native_ad_icon);
            var nativeAdTitle         = adView.FindViewById <TextView> (Resource.Id.native_ad_title);
            var nativeAdBody          = adView.FindViewById <TextView> (Resource.Id.native_ad_body);
            var nativeAdMedia         = adView.FindViewById <MediaView> (Resource.Id.native_ad_media);
            var nativeAdSocialContext = adView.FindViewById <TextView> (Resource.Id.native_ad_social_context);
            var nativeAdCallToAction  = adView.FindViewById <Button> (Resource.Id.native_ad_call_to_action);

            // Setting the Text.
            nativeAdSocialContext.Text = nativeAd.AdSocialContext;
            nativeAdCallToAction.Text  = nativeAd.AdCallToAction;
            nativeAdTitle.Text         = nativeAd.AdTitle;
            nativeAdBody.Text          = nativeAd.AdBody;

            // Downloading and setting the ad icon.
            var adIcon = nativeAd.AdIcon;

            NativeAd.DownloadAndDisplayImage(adIcon, nativeAdIcon);

            // Download and setting the cover image.
            var adCoverImage = nativeAd.AdCoverImage;

            nativeAdMedia.SetNativeAd(nativeAd);

            // Add adChoices icon
            if (adChoicesView == null)
            {
                adChoicesView = new AdChoicesView(this, nativeAd, true);
                adView.AddView(adChoicesView, 0);
            }

            nativeAd.RegisterViewForInteraction(adView);
        }
示例#25
0
 public void OnAdsLoaded()
 {
     try
     {
         NativeAd ad = NativePostAdapter2?.MNativeAdsManager?.NextNativeAd();
         if (ad != null)
         {
             NativePostAdapter2.MAdItems.Add(ad);
         }
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
示例#26
0
        protected override void CleanCurrentAD()
        {
            if (m_NativeAd == null)
            {
                return;
            }

            m_NativeAd.NativeAdDidLoad           = null;
            m_NativeAd.NativeAdDidFailWithError  = null;
            m_NativeAd.NativeAdWillLogImpression = null;
            m_NativeAd.NativeAdDidClick          = null;

            m_NativeAd.Dispose();
            m_NativeAd = null;
        }
示例#27
0
 public void OnAdsLoaded()
 {
     try
     {
         NativeAd ad = NativePostAdapter2?.MNativeAdsManager?.NextNativeAd();
         if (ad != null)
         {
             NativePostAdapter2.MAdItems.Add(ad);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
示例#28
0
    private void StartNativeAd()
    {
        Debug.Log("StartNativeAd");

        NativeAd nativeAd = new AudienceNetwork.NativeAd(uniqueId);

        this.nativeAd = nativeAd;
        nativeAd.RegisterGameObjectForImpression(gameObject, new Button[] { callToActionButton });
        coverImage.sprite = null;
        iconImage.sprite  = null;
        // 原生广告加载结束
        nativeAd.NativeAdDidLoad = (delegate()
        {
            this.Log("Native ad loaded.");
            Debug.Log("Loading images...");
            // Use helper methods to load images from native ad URLs
            StartCoroutine(nativeAd.LoadIconImage(nativeAd.IconImageURL));
            StartCoroutine(nativeAd.LoadCoverImage(nativeAd.CoverImageURL));

            Debug.Log("Images loaded.");
            title.text = nativeAd.Title;
            socialContext.text = nativeAd.SocialContext;
            callToAction.text = nativeAd.CallToAction;
            onNativeAdAdDidLoad.Invoke();
        });
        // 加载过程中出现错误
        nativeAd.NativeAdDidFailWithError = (delegate(string error)
        {
            this.Log("Native ad failed to load with error: " + error);
            onNativeAdAdDidFailWithError.Invoke(error);
        });
        // 广告日志记录
        nativeAd.NativeAdWillLogImpression = (delegate()
        {
            this.Log("Native ad logged impression.");
        });
        // 点击广告
        nativeAd.NativeAdDidClick = (delegate()
        {
            this.Log("Native ad clicked.");
            onNativeAdAdDidClick.Invoke();
        });
        nativeAd.NativeAdDidFinishHandlingClick = (delegate()
        {
            this.Log("Native ad Did Finish Handling Click.");
        });
        nativeAd.LoadAd();
    }
示例#29
0
    public void LoadAd()
    {
        NativeAd nativeAd = new NativeAd("YOUR_PLACEMENT_ID");

        this.nativeAd = nativeAd;
        if ((bool)targetAdObject)
        {
            if ((bool)targetButton)
            {
                nativeAd.RegisterGameObjectForImpression(targetAdObject, new Button[1]
                {
                    targetButton
                });
            }
            else
            {
                nativeAd.RegisterGameObjectForImpression(targetAdObject, new Button[0]);
            }
        }
        else
        {
            nativeAd.RegisterGameObjectForImpression(base.gameObject, new Button[0]);
        }
        nativeAd.NativeAdDidLoad = delegate
        {
            adLoaded = true;
            UnityEngine.Debug.Log("Native ad loaded.");
            UnityEngine.Debug.Log("Loading images...");
            StartCoroutine(nativeAd.LoadCoverImage(nativeAd.CoverImageURL));
            StartCoroutine(nativeAd.LoadIconImage(nativeAd.IconImageURL));
            UnityEngine.Debug.Log("Images loaded.");
        };
        nativeAd.NativeAdDidFailWithError = delegate(string error)
        {
            UnityEngine.Debug.Log("Native ad failed to load with error: " + error);
        };
        nativeAd.NativeAdWillLogImpression = delegate
        {
            UnityEngine.Debug.Log("Native ad logged impression.");
        };
        nativeAd.NativeAdDidClick = delegate
        {
            UnityEngine.Debug.Log("Native ad clicked.");
        };
        nativeAd.LoadAd();
        UnityEngine.Debug.Log("Native ad loading...");
    }
示例#30
0
        protected override void LoadAdInner()
        {
#if UNITY_EDITOR
            return;
#endif

            TDAdConfig data = TDAdConfigTable.GetData(m_AdName);
            if (data == null)
            {
                return;
            }

            m_AdUnitID = data.unitID;

            m_NativeAd = new AudienceNetwork.NativeAd(m_AdUnitID);

            m_NativeAd.RegisterGameObjectForImpression(gameObject, null);

            m_NativeAd.NativeAdDidLoad = (delegate()
            {
                if (On_AdTextLoadFinish != null)
                {
                    OnTextLoadFinish();
                }

                StartCoroutine(LoadIconImage());
                StartCoroutine(LoadCoverImage());
            });

            m_NativeAd.NativeAdDidFailWithError = (delegate(string error)
            {
                Log.w("Native ad failed to load with error: ");
            });

            m_NativeAd.NativeAdWillLogImpression = (delegate()
            {
                Log.i("Native ad logged impression.");
            });

            m_NativeAd.NativeAdDidClick = (delegate()
            {
                Log.i("Native ad clicked.");
            });

            m_NativeAd.LoadAd();
            return;
        }
示例#31
0
        void showNativeAd()
        {
            var placementId = Resources.GetString (Resource.String.fb_placement_id);

            nativeAd = new NativeAd(this, placementId);
            nativeAd.SetAdListener (this);

            nativeAd.LoadAd ();
        }