1. yield return StartCoroutine(MyCoroutine());

2. yield return MyCoroutine();


위 두 개가 어떻게 다른지 모르겠음

근데 해보니까 좀 다르긴 함

예를 들어서 코루틴에서 다른 객체의 코루틴을 실행할 때 

StopAllCoroutines()를 호출하면 1번은 종료되지만 2번은 종료되지 않음


private class MyClass

{

private IEnumerator MyCoroutine1

{

// Function()이 호출되면 OtherClass의 OtherCoroutine1()이 StartCoroutine()으로 호출한 코루틴 OtherCoroutine()은 종료되지 않음

yield return StartCoroutine(OtherClass.OtherCoroutine1());

}


private IEnumerator MyCoroutine2

{

// Function()이 호출되면 OtherClass의 OtherCoroutine2()가 그냥 호출한 OtherCoroutine()이 종료됨

yield return StartCoroutine(OtherClass.OtherCoroutine2());

}


private void Function()
{

StopAllCoroutines();

}

}


private class OtherClass

{

private IEnuemrator OtherCoroutine1

{

yield return StartCoroutine(OtherCoroutine());

}


private IEnumerator OtherCoroutine2

{

yield return OtherCoroutine();

}


private IEnumerator OtherCoroutine()

{

while (true) yield return null;

}

}



아래 링크는 그나마 비슷한 질문인데 도움되는 내용이 별로 없는 것 같아서 물어봄

https://forum.unity.com/threads/difference-between-yield-return-ienumerator-and-yield-return-startcoroutine.432571/