我將此腳本附加到主按鈕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();
}
}
我做到了,但沒有任何反應 –