任何人都知道如何在观众网络统一中使用FBNativeAdBridgeCallback功能

时间:2016-04-15 12:47:29

标签: c# facebook unity3d facebook-audience-network

有谁能告诉我如何使用FBNativeAdBridgeCallback功能?我基本上想知道图像何时完成加载,以便我可以显示它们。 。否则我有一个原生旗帜飞来飞去,直到Facebook完成加载它们。如果每个图像/文本一次加载一个,它看起来真的很难看。

它只是基本的原生广告示例脚本,我尝试使用IResult就像登录一样,但这使它变红。在互联网上没有这方面的文件,甚至在Facebook开发者网站上都没有,我根本找不到api。

有人可以向我解释如何在下面提供的脚本中使用它吗?

using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using AudienceNetwork;

[RequireComponent (typeof(CanvasRenderer))]
[RequireComponent (typeof(RectTransform))]
public class NativeAdTest : MonoBehaviour
{
    private NativeAd nativeAd;

    // UI elements in scene
    [Header("Text:")]
    public Text
        title;
    public Text socialContext;
    [Header("Images:")]
    public Image
        coverImage;
    public Image iconImage;
    [Header("Buttons:")]
    public Text
        callToAction;
    public Button callToActionButton;

    public GameObject hide;

    void Awake ()
    {
        // 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.
        nativeAd.RegisterGameObjectForImpression (gameObject, new Button[] { callToActionButton });

        // Set delegates to get notified on changes or when the user interacts with the ad.
        nativeAd.NativeAdDidLoad = (delegate() {
            Debug.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;
            Debug.Log ("Native ad Luke.");
        //  hide.SetActive(false);
            //FBNativeAdBridgeCallback


        });
        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 ();
        //nativeAd.nat
    }

    void OnGUI ()
    {
        // Update GUI from native ad
        coverImage.sprite = nativeAd.CoverImage;
        iconImage.sprite = nativeAd.IconImage;
    }

    void OnDestroy ()
    {
        // Dispose of native ad when the scene is destroyed
        if (this.nativeAd) {
            this.nativeAd.Dispose ();
        }
        Debug.Log ("NativeAdTest was destroyed!");
    }

//  void FBNativeAdBridgeCallback(IResult result)
//  {
//      
//  }

}

提前致谢!

1 个答案:

答案 0 :(得分:0)

AdView不允许您从FBNativeAdBridgeCallback()定义自定义侦听器。 AdView已提供5个回调,其中包括NativeAdDidLoad()

您的问题的解决方案是首先隐藏广告,然后在收到NativeAdDidLoad()并完成加载图片后,将广告置于最前面并使其可见。无需创建新的FBNativeAdBridgeCallback()