[Unity3D]Lua中使用协程coroutine和计时器timer
来源:互联网 发布:开源vpn服务器软件 编辑:程序博客网 时间:2024/04/30 08:27
习惯了unity3d的协程用法,那么我们在Unity里面怎么使用:
StartCoroutine
StopCoroutine
WaitForSeconds
首先lua也有coroutine,其实lua中的协程真的是暂停,用法和unity并非相同的概念,我的母的实现就是为了在lua中使用上述和c#统一的协程接口类。
在C#端需要写一个接口缓存lua的function并且对其进行计时回调lua的coroutine继续执行或者让这个协程‘dead’掉。
组合成2个计时器执行某个方法:
local gm = {}function gm.startTimer(name,delayTime,func)local one = CreateCoroutine(function (this,name,func) if not WaitForSeconds(this,delayTime,name) then return end if func~=nil then func() end end) StartCoroutine(one,name,func)endfunction gm.stopTimer(name)StopCoroutine(name)endreturn gm
具体使用例子:
GM.startTimer('Chiuan',1.0,function ( )Debug.Log('hello chiuan.')end)--GM.stopTimer('Chiuan')
最后,具体怎么实现还是直接贴上源码 + demo吧。
http://game.ceeger.com/forum/read.php?tid=18475&fid=16
0 0
- [Unity3D]Lua中使用协程coroutine和计时器timer
- [Unity3D]Lua中使用协程coroutine和计时器timer
- [Unity3D]计时器/Timer
- [Unity3D]计时器/Timer
- lua coroutine协程初探
- Unity3D之协程Coroutine
- unity3D之协程Coroutine
- 在 ASP.NET 中使用计时器(Timer)
- 在ASP.NET中使用计时器(Timer)
- Android中timer(计时器)的使用
- android使用timer和timertask实现计时器
- Unity3D中Coroutine介绍
- Unity3d中使用Lua
- Java计时器Timer 使用
- 【Android】计时器Timer使用
- 明明白白lua的协程(coroutine)
- Lua中的协程coroutine简介
- 关于Unity3D的协程(Coroutine)
- QUIC Design Documentand Specification Rationale(三)(即时翻译,会有多处错误)
- 纯jQuery实现的打字机的字幕效果,字体逐个输出到屏幕
- Java中将时间戳转化为Date类型
- 解读亚马逊直邮中国
- Winsock基础编程
- [Unity3D]Lua中使用协程coroutine和计时器timer
- hdu 1533 Going Home(最小权匹配KM)
- Max Points on a Line
- POJ 1655 Balancing Act(求树的重心)
- nodejs即时聊天
- 读取文本文件中的内容 简洁版
- Servlet3.0中Servlet的使用
- CSS强制换行
- Red5-1.0-Final集成到tomcat详细步骤