1、在lua中创建一个table
testClass = {
testInt = 2,
testBool = true,
testFloat = 1.2,
testString = "123",
testFun = function ()
print("表中的方法");
end
}
2、获取lua中的table通过解析器的GetTable获取,具体调用函数方法可参考toLua学习笔记六——C#获取LUA全局函数
LuaTable table = LuaMgr.GetInstance().LuaState.GetTable("testClass");
//访问其中的变量
Debug.Log(table["testInt"]);
Debug.Log(table["testBool"]);
Debug.Log(table["testFloat"]);
Debug.Log(table["testString"]);
//获取其中的函数
LuaFunction function = table.GetLuaFunction("testFun");
function.Call();