【发布时间】:2017-03-16 22:20:40
【问题描述】:
所以我在我的 unity android 项目中添加了来自 admob 的横幅广告和插页式广告。所以我在我的测试设备上对其进行了测试,我的横幅广告显示正常,但我的插页式广告不会显示。
我已经在每 11 场比赛中展示了插页式广告:
public void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "Pipe")
{
s.GameOver();
targetVelocity.y = 0;
targetVelocity.x = 0;
cube.gameObject.SetActive(false);
score.gameObject.SetActive(false);
this.anime2.enabled = true;
}
PlayerPrefs.SetInt("Ad Counter", PlayerPrefs.GetInt("Ad Counter") + 1);
if (PlayerPrefs.GetInt("Ad Counter") > 10)
{
if (interstitial.IsLoaded())
{
interstitial.Show();
}
PlayerPrefs.SetInt("Ad Counter", 0);
}
}
这是我的请求代码:
private void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId ="ca-app -pub-3960055046097211/6145173288";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Initialize an InterstitialAd.
InterstitialAd interstitial = new InterstitialAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(request);
}
当然之后我调用了 start() 中的方法。
那么问题出在哪里?我应该把这个脚本放在一个空对象上吗?
【问题讨论】:
-
在使用之前尝试记录
adUnitId,看看你得到了哪个ID。你是否用真实的 id 替换了 else 块中的 id? -
另外,您是否在 logcat 中看到任何与 admob 相关的错误/消息?
-
你试过调试这段代码吗?你能到达这条线:interstitial.Show() 吗?请求插页式()?还要检查您的 adUnitId 是否正确,因为由于某种原因可能会检测到平台错误
-
好吧,我已经检查了 adUnitId 两次,没问题?我该如何调试它?logcat?因为我是新开发人员