1.互相调用 LuaEnv luaenv = new LuaEnv(); luaenv.DoString( " print(‘Hello world‘); " ); luaenv.DoString( " CS.UnityEngine.Debug.Log(‘Hello world‘) " ); 2.自定义loader void Start() { LuaEnv env = new LuaEnv(); env.AddLoader(MyL
1.互相调用
LuaEnv luaenv = new LuaEnv(); luaenv.DoString("print(‘Hello world‘);"); luaenv.DoString("CS.UnityEngine.Debug.Log(‘Hello world‘)");
2.自定义loader
void Start() { LuaEnv env = new LuaEnv(); env.AddLoader(MyLoader); env.DoString("require ‘helloworld‘"); env.Dispose(); } private byte[] MyLoader(ref string filePath) { //print(filePath); // string s = "print(123)"; // return System.Text.Encoding.UTF8.GetBytes(s); string absPath = Application.streamingAssetsPath + "/" + filePath + ".lua.txt"; return System.Text.Encoding.UTF8.GetBytes(File.ReadAllText(absPath)); // return null; }
3.获取lua 变量
LuaEnv env = new LuaEnv(); env.DoString("require‘CSharpCallLua‘"); int a = env.Global.Get<int>("a"); print(a); env.Dispose();
4.接口映射加
[CSharpCallLua] interface IPerson { string name { get; set; } string age { get; set; } }
5.接口是引用拷贝 类是值拷贝
6. 传参要多加一个 lua 没有this
person ={
name="siki",age=100,12,2,
eat=function(self,a,b)
print(a+b);
end
}
7.