标签:
IEnumerator StartRightLiziCard()//在下面函数的调用开始执行 { yield return new WaitForSeconds(1.0f);//等待1秒针 areas[Index].energyGun.SetActive(true);//执行 } int Index = 1; public void playEnergyGun(int seatIndex, bool isPlay)//开始执行 { if (isPlay) { if (areas[seatIndex - 1].isEnergyOver) { areas[seatIndex - 1].isEnergyOver = false; Index = seatIndex - 1; StartCoroutine("StartRightLiziCard");此处执行到上面函数的接口。。。但是同时向下面代码执行。。 int spriteName = Convert.ToInt32(areas[seatIndex - 1].gunBarrel.GetComponent<UISprite>().spriteName); areas[seatIndex - 1].gunBarrel.GetComponent<UISprite>().spriteName = (spriteName + 4).ToString(); areas[seatIndex - 1].particle.Play(); } } else { if (!areas[seatIndex - 1].isEnergyOver) { areas[seatIndex - 1].isEnergyOver = true; areas[seatIndex - 1].energyGun.SetActive(false); int spriteName = Convert.ToInt32(areas[seatIndex - 1].gunBarrel.GetComponent<UISprite>().spriteName); areas[seatIndex - 1].gunBarrel.GetComponent<UISprite>().spriteName = (spriteName - 4).ToString(); areas[seatIndex - 1].particle.Play(); } } }
注意:相当于开启了一个子线程,但是主线程仍向下执行。
标签:
原文地址:http://www.cnblogs.com/heisaijuzhen/p/4390511.html