bool shouldGenerateFood = true;
void Update()
{
StartCoroutine(GenerateFood());
}
IEnumerator GenerateFood()
{
yield return new WaitUntil(() => shouldGenerateFood);
shouldGenerateFood = false;
Debug.Log("ddd");
for(int i = 0; i < foodList.Count; i ++)
{
GameObject temp = Instantiate(foodList[i]);
temp.transform.position = new Vector3(0, 0 , i * food_interval);
stageFoodList.Add(temp);
}
}