How to Reset the Time Specified in coroutine

using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.Timeline;

public class EKKOVideo : MonoBehaviour
{
    public VideoPlayer mVideoPlayer = null;

    public void Start()
    {
        mVideoPlayer.loopPointReached += FinishedVideo;
    }

    public void FinishedVideo(VideoPlayer player)
    {
        StartCoroutine(StartLoadScene());
    }

    IEnumerator StartLoadScene()
    {
       
        yield return new WaitForSeconds(300f);
        SceneManager.LoadScene("MainScenes");
    }
}

I made the screen change 5 minutes after the video is over, but I would like to reset the time if I click the video again within 5 minutes. What should I do?

If you really just want to reset the time, stop the old coroutine and start a new one. For that you will have to save the IEnumerator of the coroutine to your class. When you detect a click on the video, use that IEnumerator to stop the coroutine, then run start a new one and overwrite the old saved IEnumerator.
The documentation of StopCoroutine offers a small example for how to stop a coroutine:

You can also save the coroutine object that is returned by the StartCoroutine call itself and stop that.

1 Like