I have a function which has a yield in it. it’s called when user clicks a button and increases a variable. however I want the instructions after my yield to be executed only once and with every click I want the previous coroutine to be terminated and only the last coroutine remain so if the user keeps clicking my button it only executes the last coroutine. here’s a sample code :
var myNum = 0;
function sample(){
yield WaitForSeconds(2.0f);
myNum++;
}