class CoroutineTest : IEnumerable
    {
        public IEnumerator GetEnumerator()
        {
            yield return 1;
            yield return 2;
            yield return 3;
            yield return 4;
        }
    } CoroutineTest test = new CoroutineTest();
        foreach(int t in test)
        {
            Debug.Log(t);
        } 
return으로 아무거나 넣어줘도 성립한다
 
class Test
    {
        public int Id = 0;
    }
    class CoroutineTest : IEnumerable
    {
        public IEnumerator GetEnumerator()
        {
            yield return new Test() { Id = 1 };
            yield return new Test() { Id = 2 };
            yield return new Test() { Id = 3 };
            yield return new Test() { Id = 4 };
        }
    }CoroutineTest test = new CoroutineTest();
        foreach(var t in test)
        {
            Test value = (Test)t;
            Debug.Log(value.Id);
        } 
일반함수는 return null하면 끝나지만 어떻게 영구적으로 끝내나?
yield break;추가하면 영구적으로 종료한다
 void GenerateItem()
        {
            //아이템을 만들어준다
            //DB저장
            //이후 로직을 실행하는데 DB저장이 되기전에 아래 로직이 실행되면 큰일생김
            //멈춤(여기서 코루틴사용)
            //로직
        }AI패트롤 기능
4초뒤 터지는 스킬을 만든다고 가정
float deltaTIme = 0;
        void ExplodeAfter4Second()
        {
            deltaTIme += Time.deltaTime;
            if(deltaTIme >= 4)
            {
                //로직
            }
        }스킬마다 더하고 계산하는게 과정이 있는데 스킬이 한번에 엄청많이 사용된다면 과부하온다
IEnumerator ExplodeAfterSeconds(float seconds)
    {
        Debug.Log("Explode Enter");
        //유니티 엔진 자체에서 몇초동안 기다릴지
        yield return new WaitForSeconds(seconds);
        Debug.Log("Explode Execute!!!!");
    }StartCoroutine("ExplodeAfterSeconds", 4.0f); 
요약
Suspends the coroutine execution for the given amount of seconds using scaled time.
매개 변수
seconds:  Delay execution by the amount of time in seconds.
Coroutine co;IEnumerator ExplodeAfterSeconds(float seconds)
    {
        Debug.Log("Explode Enter");
        //유니티 엔진 자체에서 몇초동안 기다릴지
        yield return new WaitForSeconds(seconds);
        Debug.Log("Explode Execute!!!!");
        co = null;
    }
    
IEnumerator CoStopExplode(float seconds)
    {
        Debug.Log("Stop Enter");
        yield return new WaitForSeconds(seconds);
        Debug.Log("Stop Execute!!!!");
        if(co != null)
        {
            StopCoroutine(co);
            co = null;
        }
    } co = StartCoroutine("ExplodeAfterSeconds", 4.0f);
        StartCoroutine("CoStopExplode", 2.0f);