StartDelay = function() coDelay = StartCoroutine(Delay) end
Delay = function() local c = 1 whiletruedo --可以直接使用类似Unity中的协程相关方法 WaitForSeconds(1) --Yield(0) --WaitForFixedUpdate() --WaitForEndOfFrame() --Yield(异步加载返回值) print("Count: " .. c) c = c + 1 if c > 5then StopDelay() break end end end
StopDelay = function() StopCoroutine(coDelay) coDelay = nil end