LuaFramework案例_02
来源:互联网 发布:java用sleep内存泄露 编辑:程序博客网 时间:2024/06/07 08:01
4.接收,改变Lua的值
public class Studio_AccessingLuaVariables : MonoBehaviour{ string script = @"print('obj---'..obj)var2Read=42varTable={1,2,2,6}varTable.default=1varTable.map={}varTable.map.name='map'meta={name='meta'}setmetatable(varTable,meta)function testFunc(strs) print('test----'..strs);end"; void Start() { Application.logMessageReceived += ShowTips; LuaState lua = new LuaState(); lua.Start(); lua["obj"] = 5;//使obj有值 lua.DoString(script); Debugger.Log("lua 元素 {0}", lua["var2Read"]); Debugger.Log("lua 表元素 {0}", lua["varTable.default"]); LuaFunction func = lua["testFunc"] as LuaFunction; func.Call(123); func.Dispose(); LuaTable table = lua.GetTable("varTable"); Debugger.Log("defalu值为{0} map.name值为{1}", table["default"], table["map.name"]); table["map.name"] = "新值New,改变"; Debugger.Log("第二次--defalu值为{0} map.name值为{1}--改变后", table["default"], table["map.name"]); table.AddTable("newMap"); LuaTable table1 = (LuaTable)table["newMap"]; table1["name"] = "table1"; Debugger.Log("varTable.newMap 名字={0}", table1["name"]); table1.Dispose(); table1 = table.GetMetaTable(); if (table1 != null) Debugger.Log("table metatable name {0}", table1["name"]);//元表 object[] list = table.ToArray(); for (int c = 0; c < list.Length; c++) { Debugger.Log("vartable[{0}]==={1}", c, list[c]); } //LuaTable newMap = lua.GetTable("newMap") as LuaTable; //Debugger.Log("newMap['name']==={0}", newMap["name"]); table.Dispose(); lua.CheckTop(); lua.Dispose(); } string tips = null; void ShowTips(string condition, string stackTrace, LogType type) { tips += condition; tips += "\r\n"; } void OnGUI() { GUI.Label(new Rect(10, 10, 200, 200), tips); } void OnApplicationQuit() { Application.logMessageReceived -= ShowTips; }}
阅读全文
0 0
- LuaFramework案例_02
- LuaFramework案例_01
- 购物车案例_02
- Spring 简单案例(依赖注入)_02
- LuaFramework--入门
- LuaFramework 实战
- LuaFramework-打包AssetBundle工具
- unity3d LuaFramework ShareSDK
- LuaFrameWork学习----1
- 算法_02
- 1.Unity3D热更新-LuaFramework
- LuaFramework框架启动详细流程图
- Unity ToLua & LuaFramework学习笔记
- LuaFrameWork-UGUI使用说明、导入Unity
- 03_02.cs
- 单片机C51学习心得_02
- Java线程_02
- Matlab入门_02
- git pull出错
- [心得]Java基础部分心得
- 怎么解决Tomcat端口被占用的问题
- 读取String数组内的内容
- 关于hadoop的前世与今生
- LuaFramework案例_02
- 登录注册常用JQuery逻辑
- 数据导出到excel中,出现表情包,自身数据能导出,后续数据导致空白丢失,表情过滤。
- UML_使用Astah对C++代码反向建模(a.k.a cpp代码映射为类图的教程)
- 配置mysql 主从同步(mysql版本5.7.18
- Android 实现启动页面冷启动
- springboot访问html文件
- Visual Studio Code创建C#项目
- 图像bayer格式介绍以及bayer插值原理CFA