在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;
}
}