我将此脚本附加到主按钮onclick并以统一方式运行,但它显示DUMMY SHOW INTERSTITIAL
。当我在我的设备上部署时,会显示消息,“不幸的是,APP已停止”。
我尝试了很多次,只是做了一些小改动和一些重大更改,但每次都显示DUMMY INTERSTITIAL SHOW
,但是在设备上运行我的应用程序时,它给出了错误SORRY, UNFORTUNATELY APP HAS STOPPED
,这是我的主代码。任何人都可以检查这个,并告诉我是否有任何错误,或者我该怎么做才能运行这段代码。Unity5 admob插页式广告在设备中无法实现
using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;
using GoogleMobileAds;
using System;
public class AdMobController : MonoBehaviour {
InterstitialAd interstitial;
// Use this for initialization
void Start() {
//RequestBanner();
RequestInterstitial();
}
public void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId = "AD_UNIT_ID";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Initialize an 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);
// Called when an ad request has successfully loaded.
interstitial.OnAdLoaded += HandleOnAdLoaded;
// Called when an ad request failed to load.
interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;
// Called when an ad is clicked.
}
public void HandleOnAdLoaded(object sender, EventArgs args)
{
print("OnAdLoaded event received.");
// Handle the ad loaded event.
}
public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
print("Interstitial Failed to load: " + args.Message);
// Handle the ad failed to load event.
}
public void ChangeScene (int sceneToChangeTo) {
Application.LoadLevel (sceneToChangeTo);
interstitial.Show();
}
}
我做到了,但没有任何反应 –