2

Using test ads on an iPhone I can get the rewarded ad to display, but when it closes the app crashes. The function I'm using is:

public void HandleRewardBasedVideoRewarded(object sender, Reward args) {
    MonoBehaviour.print( "HandleRewardBasedVideoRewarded event received");
    StartCoroutine ( gm.noAdsReviveCountdown() );
}

The coroutine runs perfectly fine otherwise, so I don't think it has to do with that. Is there another reason for it to crash every time it tries to go back to the app from the video? I thought maybe it's because I'm not using either the sender or args parameters?


Edit: Adding the noAdsReviveCountdown function:

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

}
dulongj
  • 307
  • 2
  • 17

0 Answers0