์ด๋ ‡๊ฒŒ ์“ฐ๊ณ  ํด๋ฆญํ•˜๋‹ˆ๊นŒ A๋ž‘ B๋ž‘ ๊ฐ™์ด ์ถœ๋ ฅ๋˜๋„ค์š” ๊ณ„์†




using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test : MonoBehaviour
{
void Awake()
{
StartCoroutine(A());
}

void Update()
{
if(Input.GetMouseButtonDown(0))
{
StartCoroutine(B());
}
}

IEnumerator A()
{
while(true)
{
yield return null;
print("A");
}
}

IEnumerator B()
{
StopCoroutine("A");
while(true)
{
yield return null;
print("B");
}
}

}





Coroutine c = A();

์ด๋Ÿฐ์‹์œผ๋กœ ๋ฐ›์•„์™€์„œ ์“ฐ๋ฉด ๋ ๊ฑฐ๊ฐ™๊ธด ํ•œ๋ฐ, ๊ฒ€์ƒ‰ํ•ด๋ฒ„๋‹ˆ๊นŒ ๋ฌธ์ž์—ด๋กœ ๋ฐ”๋กœ ์จ๋„ ๋œ๋‹ค๊ณ ํ•˜๋Š”๋ฐ ์™œ ์•ˆ๋ฉˆ์ถ”๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ๋„ค์š”