简体   繁体   English

admob 广告未显示在由 unity 制作的 android 游戏中

[英]admob ads not shown in android game made by unity

anyone help me in integrating Admob ads for android game ?有没有人帮我整合安卓游戏的 Admob 广告?

from the unity editor console I see that the ads created and requested and shown and all works 100% but not shown in the android device .. why从统一编辑器控制台中,我看到创建、请求和显示的广告都 100% 有效,但未显示在 android 设备中..为什么

using UnityEngine;
using GoogleMobileAds.Api;
public class ads : MonoBehaviour
{
bool called = false;
void Start()
{

    if (Application.loadedLevelName == "gameplay")
    {
        interesRequest(called);
    }
    if (Application.loadedLevelName == "mainMenu")
    {
        bannerRequest();
    }
    if (Application.loadedLevelName == "levelScore")
    {

    }
}
void bannerRequest()
{
    BannerView bannerView = new BannerView("ca-app-pub-5443208681329246/6087569010", AdSize.Banner, AdPosition.Bottom);
    AdRequest request = new AdRequest.Builder().Build();
    bannerView.LoadAd(request);
    bannerView.Show();
}
void interesRequest(bool call)
{
    InterstitialAd inters = new InterstitialAd("ca-app-pub-5443208681329246/7564302219");
    if (call)
    {
        if (inters.IsLoaded())
        {
            inters.Show();
            called = false;
        }
    }
    else
    {
        AdRequest request = new AdRequest.Builder().Build();
        inters.LoadAd(request);
    }
}
void Update()
{
    if (called)
       interesRequest(called);
}
public void OnMouseDown()
{
    if (gameObject.name == "pause")
    {
        if (menu.bug)
        {
            called = true;
        }
    }
}

} }

You're calling request and show functions at same time.您同时调用 request 和 show 函数。 This is impossible to make request and show ads at same time.这是不可能同时发出请求和显示广告的。 Make requests in OnStart() function, and when level is changed or whenever you want show banner or interstatial ad.在 OnStart() 函数中发出请求,以及何时更改级别或在您想要显示横幅广告或国际广告时发出请求。 Because they need some time to download ads.因为他们需要一些时间来下载广告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM