this.StartCoroutine(Test(a));
IEnumerator Test(int a)
{
Debug.log("1");
yield return null;
gameObject.SetActive(false);
yield return nulll; // 这里携程就退出了,不会再执行。因为物体隐藏了。
gameObject.SetActive(true);
yield return null;
}
利用这个特点,隐藏物体也是一种停止挂在这物体上所有协程的方法。