- Home /
how do i stop/exit a coroutine?
how can i stop or exit function while its working? my code is below
function ChangeColor(){
timer = 0;
RandomNumber=Random.Range(5,9);
yield WaitForSeconds(RandomNumber);
renderer.material.SetTexture("_MainTex", yellow);
cc=1;
}
i want to stop this function or change "waitforseconds" time while the program waiting for "randomnumber". for some reason, i just wanna let it finish running this function as soon as possible.
any help would be appreciated
Answer by Joshua · Aug 16, 2011 at 05:07 PM
This is not exactly a function, it's a coroutine. To exit them while they are being run you can use MonoBehaviour.StopCoroutine();
Your answer
![](https://koobas.hobune.stream/wayback/20220612182109im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
How do I Stop a Function ? 2 Answers
How to stop coroutine with parameters? 3 Answers
Close/Exit video played with Handheld.PlayFullScreenMovie 2 Answers
Is there a way to break out of a function and return control to another script's function? 1 Answer