Ulua_toLua_基本案例(六)_LuaCoroutine2
案例 基本
2023-09-14 09:08:54 时间
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; } }
相关文章
- 网络访问控制列表ACL(读懂这篇就基本够了,后面有配置案例)[通俗易懂]
- 案列:流程控制练习案例
- JavaScript案例:仿京东显示密码
- C#时间戳基本使用案例分享
- Python编程经典案例【考题】找出两个字符串中相同字符和不同字符
- Linux 应用案例开发手册——基于Zynq-7010/20工业开发板
- 典中典 - 国外漏洞挖掘案例
- postgresql 获取两个时间类型小时差值案例
- spring原理案例-基本项目搭建 01 spring framework 下载 官网下载spring jar包详解编程语言
- spring原理案例-基本项目搭建 02 spring jar包详解 spring jar包的用途编程语言
- PHP(Mysql/Redis)消息队列的介绍及应用场景案例详解编程语言
- Golang指针基本介绍及使用案例详解编程语言
- 针对TP-LINK的CSRF攻击来劫持DNS案例