Ulua_toLua_基本案例(六)_LuaCoroutine2
2016-03-01 16:00
495 查看
Ulua_toLua_基本案例(六)_LuaCoroutine2
using UnityEngine; using System.Collections; using LuaInterface; public class TestCoroutine2 : MonoBehaviour { LuaState luaState = null; string script = @" function CoExample() WaitForSeconds(2) print('WaitForSeconds end time: '.. UnityEngine.Time.time) WaitForFixedUpdate() print('WaitForFixedUpdate end frameCount: '..UnityEngine.Time.frameCount) WaitForEndOfFrame() print('WaitForEndOfFrame end frameCount: '..UnityEngine.Time.frameCount) Yield(null) print('yield null end frameCount: '..UnityEngine.Time.frameCount) Yield(0) print('yield(0) end frameCime: '..UnityEngine.Time.frameCount) local www = UnityEngine.WWW('http://www.baidu.com') Yield(www) print('yield(www) end time: '.. UnityEngine.Time.time) local s = tolua.tolstring(www.bytes) print(s:sub(1, 128)) print('coroutine over') end function TestCo() print('TestCo') local co = coroutine.create(CoExample) local flag, msg = coroutine.resume(co) if not flag then error(msg) end end "; void Awake () { luaState = new LuaState(); luaState.Start(); LuaBinder.Bind(luaState); LuaCoroutine.Register(luaState, this); luaState.DoString(script); LuaFunction func = luaState.GetFunction("TestCo"); func.Call(); func.Dispose(); } void OnDestroy() { luaState.Dispose(); luaState = null; } }
相关文章推荐
- Lua学习笔记-string库的使用
- Lua的语法缺失及替代措施
- lua 类、继承、多重继承
- Lua处理中英文混合字符串
- lua 与 c 的相互调用
- Visual Studio2012 Lua插件--BabeLua
- 请教大家关于wireshark添加lua自定义规则解析模块的问题
- 55.Evaluate the following two queries:
- 55.Evaluate the following two queries:
- lua 库
- lua zmq client
- lua zmq server
- 如何在Windows平台使用VS搭建C++/Lua的开发环境
- lua 快速排序
- lua中的坑
- cordova build 报错:failed to notfy projectevluationlistener.afterevaluate<>.
- Ulua_toLua_基本案例(五)_LuaCoroutine
- Ulua_toLua_基本案例(四)_AccessingLuaVariables
- Ulua_toLua_基本案例(三)_CallLuaFunction
- Ulua_toLua_基本案例(二)_ScriptsFromFile