/// <summary> /// 注册方法按钮点击 /// </summary> public void registerMethodButtonClickedHandler() { if (!_isRegMethod) { LuaContext.currentContext.registerMethod("getDeviceInfo", (arguments) => { Dictionary <string, LuaValue> info = new Dictionary <string, LuaValue>(); info.Add("productName", new LuaValue(Application.productName)); return(new LuaValue(info)); }); LuaContext.currentContext.registerMethod("testReturnTuple", (arguments) => { LuaTuple tuple = new LuaTuple(); tuple.addRetrunValue("Hello"); tuple.addRetrunValue(2017); tuple.addRetrunValue("World"); tuple.addRetrunValue(111); return(new LuaValue(tuple)); }); _isRegMethod = true; } LuaContext.currentContext.evalScriptFromFile(string.Format("{0}/main.lua", Application.streamingAssetsPath)); }
public void coroutineButtonClickedHandler() { if (!_isCoroutineImport) { _isCoroutineImport = true; LuaContext.currentContext.registerModule <Person> (); LuaContext.currentContext.registerModule <LogModule> (); LuaContext.currentContext.registerModule <LuaClassImport> (); LuaClassImport.setIncludesClasses(LuaContext.currentContext, new List <Type> () { typeof(Person), typeof(NativeData) }); LuaContext.currentContext.registerMethod("GetValue", (arguments) => { return(new LuaValue(1024)); }); LuaContext.currentContext.registerMethod("GetPixel", (arguments) => { LuaTuple tuple = new LuaTuple(); tuple.addRetrunValue(100); tuple.addRetrunValue(38); tuple.addRetrunValue(1002); return(new LuaValue(tuple)); }); } LuaContext.currentContext.evalScriptFromFile("coroutine.lua"); }
public void coroutineButtonClickedHandler() { if (!_isCoroutineImport) { _isCoroutineImport = true; LuaContext.currentContext.registerMethod("GetValue", (arguments) => { return(new LuaValue(1024)); }); LuaContext.currentContext.registerMethod("GetPixel", (arguments) => { LuaTuple tuple = new LuaTuple(); tuple.addRetrunValue(100); tuple.addRetrunValue(38); tuple.addRetrunValue(1002); return(new LuaValue(tuple)); }); } LuaContext.currentContext.evalScriptFromFile("coroutine.lua"); }