Admob广告未在Unity,C#中展示

我的Admob广告没有显示在Android上的应用中,我尝试了所有操作,不同版本的统一性,广告类型,admob插件的重新安装,用于Android编译的播放器设置的不同组合。

登录Unity(我在Android上进行了测试)是

Dummy IsLoaded
虚拟ShowIntertitial

代码:

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

public class ControllerMain : MonoBehaviour
{

public Button LV1,LV2,LV3,LV4,LV5,LV6,LV7,LV8,LV9,LV10;
public int ReturnedVal;
private string MyIdA = "ca-app-pub-3940256099942544/1033173318";
//private InterstitialAd fullscreenad;
//private string FullScreenID = "ca-app-pub-3940256099942544/1033173651";
//private BannerView bannerView;
private InterstitialAd InterFULLSC;
void LOV1() {
    SceneManager.LoadScene(1);
}
void LOV2()
{
    SceneManager.LoadScene(2);
}
void LOV3()
{
    SceneManager.LoadScene(3);
}
void LOV4()
{
    SceneManager.LoadScene(4);
}
void LOV5()
{
    SceneManager.LoadScene(5);
}
void LOV6()
{
    SceneManager.LoadScene(6);
}
void LOV7()
{
    SceneManager.LoadScene(7);
}
void LOV8()
{
    SceneManager.LoadScene(8);
}
void LOV9()
{
    SceneManager.LoadScene(9);
}
void LOV10()
{
    SceneManager.LoadScene(10);
}
// Start is called before the first frame update
void Start()
{
    MobileAds.Initialize(initStatus => { });
    this.InterFULLSC = new InterstitialAd(MyIdA);
    //LV1.getcomponent<Image>().color = Color.black;
    ReturnedVal = GameMonitor.IsPassed;
    if (ReturnedVal > 0)
    {
        AdRequest requ = new AdRequest.Builder().Build();
        this.InterFULLSC.LoadAd(requ);

        if (this.InterFULLSC.IsLoaded()) {
            this.InterFULLSC.Show();
        }
        //MobileAds.Initialize(appID);
        //go
        //bannerView = new BannerView("ca-app-pub-3940256099942544/6300978111",AdSize.Banner,AdPosition.Bottom);
        //AdRequest requ = new AdRequest.Builder().Build();
        //bannerView.LoadAd(requ);
        //bannerView.Show();
        //end
        //fullscreenad = new InterstitialAd(FullScreenID);
        //AdRequest request = new AdRequest.Builder().Build();
        //fullscreenad.LoadAd(request);
        //if (fullscreenad.IsLoaded())
        //{
        //    fullscreenad.Show();
        //}
        //else { Debug.Log("Didn't load"); }

    }
    Debug.Log(ReturnedVal);
    LV1.getcomponent<Image>().color = Color.green;
    LV2.getcomponent<Image>().color = Color.black;
    LV3.getcomponent<Image>().color = Color.black;
    LV4.getcomponent<Image>().color = Color.black;
    LV5.getcomponent<Image>().color = Color.black;
    LV6.getcomponent<Image>().color = Color.black;
    LV7.getcomponent<Image>().color = Color.black;
    LV8.getcomponent<Image>().color = Color.black;
    LV9.getcomponent<Image>().color = Color.black;
    LV10.getcomponent<Image>().color = Color.black;
    LV2.interactable = false;
    LV3.interactable = false;
    LV4.interactable = false;
    LV5.interactable = false;
    LV6.interactable = false;
    LV7.interactable = false;
    LV8.interactable = false;
    LV9.interactable = false;
    LV10.interactable = false;
    LV1.interactable = true;
    LV1.onClick.AddListener(LOV1);
    if (ReturnedVal == 2 || ReturnedVal>2) {
        LV2.interactable = true;
        LV2.getcomponent<Image>().color = Color.green;
        LV2.onClick.AddListener(LOV2);
    }
    if (ReturnedVal == 3 || ReturnedVal > 3)
    {
        LV3.interactable = true;
        LV3.getcomponent<Image>().color = Color.green;
        LV3.onClick.AddListener(LOV3);
    }
    if (ReturnedVal == 4 || ReturnedVal > 4)
    {
        LV4.interactable = true;
        LV4.getcomponent<Image>().color = Color.green;
        LV4.onClick.AddListener(LOV4);
    }
    if (ReturnedVal == 5 || ReturnedVal > 5)
    {
        LV5.interactable = true;
        LV5.getcomponent<Image>().color = Color.green;
        LV5.onClick.AddListener(LOV5);
    }
    if (ReturnedVal == 6 || ReturnedVal > 6)
    {
        LV6.interactable = true;
        LV6.getcomponent<Image>().color = Color.green;
        LV6.onClick.AddListener(LOV6);
    }
    if (ReturnedVal == 7 || ReturnedVal > 7)
    {
        LV7.interactable = true;
        LV7.getcomponent<Image>().color = Color.green;
        LV7.onClick.AddListener(LOV7);
    }
    if (ReturnedVal == 8 || ReturnedVal > 8)
    {
        LV8.interactable = true;
        LV8.getcomponent<Image>().color = Color.green;
        LV8.onClick.AddListener(LOV8);
    }
    if (ReturnedVal == 9 || ReturnedVal > 9)
    {
        LV9.interactable = true;
        LV9.getcomponent<Image>().color = Color.green;
        LV9.onClick.AddListener(LOV9);
    }
    if (ReturnedVal == 10)
    {
        LV10.interactable = true;
        LV10.getcomponent<Image>().color = Color.green;
        LV10.onClick.AddListener(LOV10);
    }
    }

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


    }
    }
mystiquec 回答:Admob广告未在Unity,C#中展示

使用以下格式初始化广告:

/root/requirements.txt

您还尝试在开始功能中一起加载和展示广告,这可能是您所遇到问题的原因之一。 将广告加载到开始功能中,但通过调用以下功能在点击任何按钮时展示广告

MobileAds.Initialize(appID);
本文链接:https://www.f2er.com/3127999.html

大家都在问