【发布时间】:2018-08-03 20:24:36
【问题描述】:
我正在尝试这样的事情: if button clicked for 4 times, I could show Interstitial?
但是我做不到。
创建了一个游戏对象。 将脚本附加到该对象。 创建了一个重新启动按钮。 仅使用 onclick-runtime 等在该按钮上实现此对象。
现在每次用户点击重新启动按钮时,插页式广告都会自动显示。但当然你可能知道,这很烦人。
我不知道如何计算用户按下重新启动按钮的次数,例如,如果用户按下按钮,则每 3 或 4 次显示广告。
谢谢。
using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;
public class AdScript : MonoBehaviour
{
InterstitialAd interstitial;
public string InterstitialId;
// Use this for initialization
void Start()
{
//Request Ads
//RequestBanner();
RequestInterstitial();
}
public void showInterstitialAd()
{
//Show Ad
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
private void RequestInterstitial()
{
string adUnitId = InterstitialId;
// 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);
}
}
【问题讨论】: