Unity AdMob |我的广告正在加载,但虚拟广告不会展示

时间:2018-07-25 20:43:57

标签: unity3d

这是我的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
using System;

public class AdScript : MonoBehaviour {

// Use this for initialization
void Start () {

    string adUnitId = "ca-app-pub-3940256099942544/1033173712";

    // Initialize an InterstitialAd.
    InterstitialAd interstitial = new InterstitialAd(adUnitId);

    // Create an empty ad request.
    AdRequest request = new AdRequest.Builder().Build();
    // Load the interstitial with the request.
    interstitial.LoadAd(request);

    Debug.Log("Hello");

    if (interstitial.IsLoaded())
    {
        Debug.Log("Is Loaded");
        interstitial.Show();
    }

}

// Update is called once per frame
void Update () {

}

public void HandleOnAdLoaded(object sender, EventArgs args)
{
    MonoBehaviour.print("HandleAdLoaded event received");
}

public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
    MonoBehaviour.print("HandleFailedToReceiveAd event received with message: "
                        + args.Message);
}

public void HandleOnAdOpened(object sender, EventArgs args)
{
    MonoBehaviour.print("HandleAdOpened event received");
}

public void HandleOnAdClosed(object sender, EventArgs args)
{
    MonoBehaviour.print("HandleAdClosed event received");
    Application.LoadLevel(0);
}

public void HandleOnAdLeavingApplication(object sender, EventArgs args)
{
    MonoBehaviour.print("HandleAdLeavingApplication event received");
}

}

对于我的日志,将显示所有的调试日志,包括所有的Dummy已加载和Dummy展示广告。

如果您想知道的话,我正在实际的设备上进行测试。 nexus 5与我的所有程序完美配合。并曾经使用过Ad的测试。

0 个答案:

没有答案
相关问题