Ejemplo n.º 1
0
    private void LoadingBannerAdSuccessful()
    {
        string isAdValid = bannerAdView.IsValid() ? "valid" : "invalid";

        AdvertEngine.Instance.BannerAdLoadedSuccessfuly();
        StatusShow.instance.ShowAdStatus("Banner loaded and is " + isAdValid + ".");
    }
    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();
    }