using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
bool a = true;
bool b = true;
void Update()
{
if (a)
{
a = false;
for (int i = 0; i < 3; i++)
{
if (b)
{
b = false;
StartCoroutine("Wait");
Invoke("Stop", 5);
}
else
{
i--;
}
}
a = true;
}
}
IEnumerator Wait()
{
int i = 0;
while (i<5)
{
yield return new WaitForSeconds(1);
i++;
Debug.Log(i);
}
}
void Stop()
{
StopCoroutine("Wait");
b = true;
}
}