我在 Unity3D 中使用 Unity 广告实施了 AdMob 中介。
我在 AdMob 中介网络中完全添加了 Unity 广告,但我的应用不会显示来自 Unity Ads 的广告,它只显示来自 AdMob 的广告。
我的脚本中缺少什么?下面是我的脚本。
using System;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;
using GoogleMobileAds;
using GoogleMobileAds.Api;
using UnityEngine;
using UnityEngine.Advertisements;
public class UIManager : MonoBehaviour
{
//AdMob
private InterstitialAd interstitial;
//End
}
void Awake()
{
RequestInterstitial ();
}
private void RequestInterstitial()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "ca-app-pub-250631676/1043270594";
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create an interstitial.
interstitial = new InterstitialAd(adUnitId);
// Register for ad events.
interstitial.OnAdLoaded += HandleInterstitialLoaded;
interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad;
interstitial.OnAdOpening += HandleInterstitialOpened;
interstitial.OnAdClosed += HandleInterstitialClosed;
interstitial.OnAdLeavingApplication += HandleInterstitialLeftApplication;
// Load an interstitial ad.
interstitial.LoadAd(createAdRequest());
}
private void ShowInterstitial()
{
if (interstitial.IsLoaded())
{
interstitial.Show();
}
else
{
print("Interstitial is not ready yet.");
}
}
//Unity Ads
public void ShowAd()
{
if (Advertisement.IsReady())
{
Advertisement.Show();
}
}
//End
private AdRequest createAdRequest()
{
return new AdRequest.Builder ().Build ();
}
非常感谢你的帮助。