Unity3D中的非页内广告

时间:2015-04-02 13:24:12

标签: c# unity3d

有人可以告诉我,如何在应用中制作插页式广告?

https://developers.google.com/mobile-ads-sdk/docs/games#unity

他们说

基本插页式广告请求 以下是加载插页式广告所需的最少代码。

using GoogleMobileAds.Api;
…
private void RequestInterstitial()
{
#if UNITY_ANDROID
    string adUnitId = "INSERT_ANDROID_INTERSTITIAL_AD_UNIT_ID_HERE";
#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);}

之后

private void GameOver()
{
if (interstitial.IsLoaded()) {
interstitial.Show();
}}

但插页式变量对于函数是私有的,我无法在代码中使用它。 当我在类顶部初始化它时,统一抛出错误。有人可以写一些小教程,如何在app中使用新插件显示插页式广告?

0 个答案:

没有答案