【发布时间】:2020-08-25 12:29:26
【问题描述】:
当我使用 unity 时,控制台显示 Dummy LoadAD、Dummy Show 等。 但是当我在手机上测试它时,它确实显示了任何广告。 我将这两个功能设置在两个按钮上。横幅广告按钮不显示横幅广告。 videoAD 按钮将关闭我的应用程序
这是我的代码
using UnityEngine;
using GoogleMobileAds.Api;
using System;
using UnityEngine.UI;
public class admanageger : MonoBehaviour
{
public Text adstatus;
BannerView bannerView;
RewardedAd rewardedAd;
string appID = "ca-app-pub-#####~#####";
// Start is called before the first frame update
private void Awake()
{
}
void Start()
{
MobileAds.Initialize(appID);
}
public void showbannerAD()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-####/####";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-###/#####";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
this.bannerView.LoadAd(request);
}
public void showvideoAD()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-#####/####";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-#####/#####";
#else
string adUnitId = "unexpected_platform";
#endif
this.rewardedAd = new RewardedAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the rewarded ad with the request.
this.rewardedAd.LoadAd(request);
this.rewardedAd.Show();
}
}
我是否做错了什么或设置了有关 Admob 的需求?
【问题讨论】: