So I'm here want to make function when the user closed the Ads before video ads end, the function is stopping or revert, in this case, I'm using ienumerator methods, but I don't know how to add the handler on Ads, because I already using HandleRewardClosed method not like I want but because its same with user watch the vid till end not closed the videos before ended .

    public void loadRewardVideo()
        rewardedAd.LoadAd(new AdRequest.Builder().Build(), rewarded_Ad_ID);

        rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
        rewardedAd.OnAdClosed += HandleRewardedAdClosed;
        rewardedAd.OnAdOpening += HandleRewardedAdOpening;
        rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
        rewardedAd.OnAdRewarded += HandleUserEarnedReward;
        rewardedAd.OnAdLeavingApplication += HandleOnRewardAdleavingApp;


    /// rewarded video events //////////////////////////////////////////////

    public event EventHandler<EventArgs> OnAdLoaded;

    public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad;

    public event EventHandler<EventArgs> OnAdOpening;

    public event EventHandler<EventArgs> OnAdStarted;

    public event EventHandler<EventArgs> OnAdClosed;

    public event EventHandler<Reward> OnAdRewarded;

    public event EventHandler<EventArgs> OnAdLeavingApplication;

    public event EventHandler<EventArgs> OnAdCompleted;

    /// Rewared events //////////////////////////

    public void HandleRewardedAdLoaded(object sender, EventArgs args)
        Debug.Log("Video Loaded");

    public void HandleRewardedAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
        Debug.Log("Video not loaded");

    public void HandleRewardedAdOpening(object sender, EventArgs args)
        Debug.Log("Video Loading");

    public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
        Debug.Log("Video Loading failed");

    public void HandleRewardedAdClosed(object sender, EventArgs args)
        Debug.Log("Video Loading failed");


    IEnumerator ClosedAds()
        _GameManager.instance.isGameOver = true;
        yield return new WaitForSeconds(.05f);
        _GameManager.instance.isStarted = false;

        Time.timeScale = 0;



  • \$\begingroup\$ So you want to know when a user closed the ad before the end, and you thought about using the OnAdClosed functions to do this, but you realized that OnAdClosed is called whether the user watched the ad or not, is that it? \$\endgroup\$ – Vaillancourt Feb 15 at 16:27
  • \$\begingroup\$ Yeah, @Vaillancourt want to know the user closed the ad before the end, so I'm using OnAdClosed then it turns out the same function when the user watched the ad until the end. \$\endgroup\$ – YouCanCallMe Syarif Feb 15 at 16:39
  • 1
    \$\begingroup\$ I'm not familiar with this API, but maybe you could add some kind of "flag" bool UserWatchedTheAd = false; to your class, so that when the user watches the ad (either through HandleUserEarnedReward or HandleOnRewardAdleavingApp), in your functions, you set that flag to true, so when you get to HandleRewardedAdClosed, you check the flag, and from it, deduce whether they watched the ad? \$\endgroup\$ – Vaillancourt Feb 15 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.