自从2天以来我一直在努力弄清楚为什么地球上的人只是在展示TestAds!当我使用testId时,它会显示测试广告。当我使用我的admob横幅ID时,它变为空白(没有显示广告) 下面我附上了我的admob横幅代码。
using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;
public class AdmobScript : MonoBehaviour
{
public string BannerId;
// Use this for initialization
void Start()
{
//Request Ads
RequestBanner();
}
private void RequestBanner()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxx";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the bottom of the screen.
BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
}
}

我试图研究它为什么不起作用,但不幸的是,在互联网上可以找到非常少的统一相关的admob解决方案。
Google移动广告插件v3.13.1
Unity 2017.4.0f1
请帮帮我!谢谢!
答案 0 :(得分:0)
using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;
public class AdmobScript : MonoBehaviour
{
private string BannerId;
// Use this for initialization
void Awake()
{
//Request Ads
RequestBanner();
}
private void RequestBanner()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "You UNIT-ID HERE";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the bottom of the screen.
BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
}
}
确保UNIT-ID正确无误。不要放置您的APP-ID而不是UNIT-ID。
答案 1 :(得分:0)
我遇到了类似的问题,事实证明,除非您设置了付款信息,否则AdMob不会投放广告。所以请确保已设置。
此外,从使用测试广告切换到实际广告时,您需要确保更改应用ID和设备ID。看起来您可能只是在更改您的设备ID。
项目中的其他地方你应该有这样的东西:
using System.Collections;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdInitializer : MonoBehaviour {
public void Start()
{
#if UNITY_ANDROID
string appId = "ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX";
#elif UNITY_IPHONE
string appId = "ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX";
#else
string appId = "unexpected_platform";
#endif
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(appId);
Debug.Log ("Initializing ads for app ID " + appId);
}
}
确保这是使用您的应用ID,而不是测试应用ID。