IEnumerator CountDown()
{
while (!isCode)
{
yield return new WaitForSeconds(5.0f);
isCode = true;
}
Debug.Log("timer=" + timer);
}
private MonoBehaviour monoBehaviour = new MonoBehaviour();
monoBehaviour.StartCoroutine(CountDown());//报错
用的类是public class UIBind : TTUIPage,没有继承MonoBehaviour,
有什么办法能在这个类中实现倒计时功能呢?
MonoBehaviour以及它的子类不能被new出来,你new的时候编辑器会有警告提示,只能找一个继承过MonoBehaviour的东西,然后obj.StartCoroutine(CountDown())这样来做