Google AdMob广告未在Unity中展示

我正在制作“飞扬的小鸟”游戏,并试图在小鸟死后显示广告。 我分别从Google Admob控制台和Unity仪表板设置了Google Admob和UnityAds。

这是我的下面的代码。

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

public class GameController : MonoBehaviour {
    public static GameController instance;
    public GameObject gameOverText;
    public bool isGameOver = false;
    public float scrollSpeed = -1.5f;
    public Text scoreText;
    private int score = 0;
    private InterstitialAd interstitialAd; 
    // Awake is called before Start
    void Awake() {
        if(instance == null) {
            instance = this;
        } else if (instance != null) {
            Destroy(gameObject);
        }
    }
    // Start is called before the first frame update
    void Start() {
        MobileAds.Initialize(initStatus => { });
        RequestInterstitial();
    }


    private void RequestInterstitial() {
        string adUnitId = "unexpected_platform";
#if UNITY_ANDROID
        adUnitId = Values.TEST_ANDROID_AD_UNIT_ID;
#endif
        // Initialize InterstitialAd
        this.interstitialAd = new InterstitialAd(adUnitId);
        // Create empty ad request
        AdRequest request = new AdRequest.Builder().Build();
        // Load interstitial with the request
        this.interstitialAd.LoadAd(request);
    }

    public void ShowAd() {
        if (this.interstitialAd.IsLoaded()) {
            this.interstitialAd.Show();
        }
    }

    // Update is called once per frame
    void Update() {
        if(isGameOver && Input.GetKey(KeyCode.Space)) {
            SceneManager.LoadScene(SceneManager.GetactiveScene().buildIndex);
        } else if (isGameOver && Input.touchCount > 0) {
            SceneManager.LoadScene(SceneManager.GetactiveScene().buildIndex);
        }
    }

    public void BirdScored() {
        if(isGameOver) {
            return;
        }
        score++;
        scoreText.text = "Score: " + score;
    }

    public void BirdDied() {
        gameOverText.Setactive(true);
        isGameOver = true;
        ShowAd();
    }
}

当我调试但代码未显示时,代码到达ShowAd()函数。

我在做什么错了?

mimanzhou 回答:Google AdMob广告未在Unity中展示

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3128566.html

大家都在问