【发布时间】:2017-09-29 13:44:13
【问题描述】:
在我的统一应用程序中,我集成了 Admob。 这是我的“广告”类中的代码:
public static InterstitialAd interstitial;
private void Start()
{
RequestInterstitial();
}
public void StartAds()
{
RequestInterstitial();
if (interstitial.IsLoaded())
{
interstitial.Show();
}
else
{
Debug.Log("Interstitial wasn't loaded yet");
}
interstitial.Show();
}
public static void onAdLeftApplication()
{
ChangeCoinValue.actualCoinValue += 33;
PlayerPrefs.SetInt("TotalCoinValue", ChangeCoinValue.actualCoinValue);
}
private void RequestInterstitial()
{
// 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);
}
当我在另一个班级并打电话时,广告确实显示得非常完美(例如点击按钮:)
Ads.Interstitial.Show();
我正在这样做,因为在单声道开发中你不能使用对象,所以它需要是静态的。但是:
所以我认为我的广告类中的函数“OnAdLeftApplication()” 每次用户点击广告并因此离开应用程序时触发。如果他或她这样做,我会奖励这个人33个硬币!
但它不起作用。也许不是因为我只是从我的插页式广告中调用“show()”函数,但我不知道。
您能否向我解释一下,当用户点击其中一个广告时,我如何获得硬币奖励?
谢谢!
【问题讨论】: