我正在使用以下代码在我的游戏屏幕底部以统一的方式实现横幅广告。
using GoogleMobileAds.Api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AdScript : MonoBehaviour {
// Use this for initialization
void Start () {
showBannerAd();
}
private void showBannerAd()
{
string adID = "ca-app-pub-***********";
//***For Testing in the Device***
AdRequest request = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator.
.AddTestDevice("***********") // My test device.
.Build();
//***For Production When Submit App***
//AdRequest request = new AdRequest.Builder().Build();
BannerView bannerAd = new BannerView(adID, AdSize.SmartBanner, AdPosition.Bottom);
bannerAd.LoadAd(request);
}
// Update is called once per frame
void Update () {
}
}
当我运行它时,我收到有关日志的通知:
Dummy .ctor Dummy Createbannerview Dummy LoadAd
但不是一个模拟弹出横幅说“这里将实施横幅广告”
广告是在发布时实现还是我误解了教程中的一个步骤?
只有在构建到ios或Android并在目标设备上运行时,才会显示Admob横幅。你永远不会在统一编辑器中看到横幅。如果您运行测试广告并不重要,它们就不会在编辑器中显示。