在 iPhone 上使用测试广告我可以显示奖励广告,但是当它关闭应用程序时会崩溃。我正在使用的功能是:
public void HandleRewardBasedVideoRewarded(object sender, Reward args) {
MonoBehaviour.print( "HandleRewardBasedVideoRewarded event received");
StartCoroutine ( gm.noAdsReviveCountdown() );
}
否则协程运行得非常好,所以我认为它与此无关。每次尝试从视频返回应用程序时,是否还有其他原因导致它崩溃?我想也许是因为我没有使用 sender 或 args 参数?
编辑:添加 noAdsReviveCountdown 函数:
// No Ad Revive Countdown function - after 3 seconds the game will resume
public IEnumerator noAdsReviveCountdown() {
continueButton.interactable = false;
continueText.gameObject.SetActive (false);
adReviveButton.gameObject.SetActive (false);
noAdsReviveCountdownText.gameObject.SetActive (true);
timeLeft = 3;
while (timeLeft >= 0) {
noAdsReviveCountdownText.text = timeLeft.ToString();
noAdsReviveCountdownAnim.ResetTrigger ("CountdownTrigger");
noAdsReviveCountdownAnim.SetTrigger ("CountdownTrigger");
yield return new WaitForSecondsRealtime(1.0f);
timeLeft--;
}
if (timeLeft < 0) {
var balls = GameObject.FindGameObjectsWithTag ("ball");
foreach (var ball in balls) {
Destroy (ball);
}
noAdsReviveCountdownText.gameObject.SetActive (false);
continueButton.gameObject.SetActive (false);
Time.timeScale = 1;
}
}