public void StartLuaSvr(Action <bool> onComplete) { string initModulePath = GetModulePath(m_luaInitModuleName); TextAsset initModuleAsset = null; initModuleAsset = ResourceManager.Instance.LoadAsset <TextAsset>(initModulePath); if (initModuleAsset == null) { Debug.LogError("StartLuaSvr fail load initModuleAsset fail"); onComplete(false); } // 构造lua state 环境 m_luaSvr = new LuaSvr(); // 设置lua模块加载器 LuaSvr.mainState.loaderDelegate = LuaLoader; // 初始化lua环境 m_luaSvr.init(null, () => { // 加载初始化模块 if (!string.IsNullOrEmpty(m_luaInitModuleName)) { m_luaSvr.start(m_luaInitModuleName); } }); onComplete(true); }
// Use this for initialization void Start() { l = new LuaSvr(); l.init(null, () => { l.start("delegate"); }); }
void StartLuaScript() { // Make sure that we got script file before start if (luaScript != null) { // Initializing svr = new LuaSvr(); svr.init(null, () => { object obj; // Reading lua scripts if (svr.luaState.doBuffer(luaScript.bytes, "Here can be any name but should unique", out obj)) { // Calling main function from lua script LuaFunction func = (LuaFunction)svr.luaState["main"]; if (func != null) { self = (LuaTable)func.call(); update = (LuaFunction)self["update"]; } else { Debug.LogError("No main function"); } } else { Debug.LogError("Can not read scripts"); } }); } }
public void Close() { m_luaServer = null; if (m_luaUpdate != null) { m_luaUpdate.Dispose(); m_luaUpdate = null; } if (m_luaUpdate != null) { m_luaLateUpdate.Dispose(); m_luaLateUpdate = null; } if (m_FixedUpdate != null) { m_FixedUpdate.Dispose(); m_FixedUpdate = null; } m_inited = false; m_progress = 0; LuaSvr.mainState = null; }
public void StopSvr() { if (m_luaSvr == null) { return; } if (!m_launched) { SLua.Logger.LogError("lua虚拟机还没启动完成"); return; } Application.logMessageReceived -= UnityLogCallback; //监听unitys的log m_luaTable = null; m_luaState.loaderDelegate = null; m_luaState.Dispose(); m_luaUpdate = null; m_luaLateUpdate = null; m_luaNotify = null; m_luaNotifyError = null; m_luaState = null; m_luaSvr = null; m_launched = false; LuaEvtCenter.Enable = false; //errorDelegateLua = null; //因为是static,由外面自己维护 }
void Start() { lua = new LuaSvr(); self = (LuaTable)lua.start("LuaFiles/building_txt"); //self = (LuaTable)lua.luaState.getObject("data"); //object o = lua.luaState.getFunction("GetData").call(); Debug.Log("table " + ((LuaTable)self[1])["name"]); LuaFunction dataFunction = ((LuaFunction)self["GetData"]); LuaTable dataTable = (LuaTable)dataFunction.call(); LuaFunction callFunction = (LuaFunction)self["CallBack"]; callFunction.call(222); //lua.luaState.getFunction("CallBack").call(); lua.luaState.getFunction("Call").call(2); Debug.Log("table " + ((LuaTable)dataTable[1])["use_money"] + " is Null " + (callFunction == null)); LuaTable d = (LuaTable)((LuaFunction)self["GetData1"]).call(); Debug.Log("---------------- : " + ((LuaTable)d[1])["use_money"]); LuaTable table2 = (LuaTable)lua.start("LuaFiles/building_txt1"); test2 = (LuaFunction)self["test"]; object o = test2.call(self, 9, 1); Debug.Log("add function :" + o); SetTransform = (LuaFunction)self["SetTransform"]; SetTransform.call(self, tr); //tr.localPosition = new Vector3(2, 2, 2); }
void Start() { Application.targetFrameRate = LGameConfig.DEFAULT_FRAME_RATE; if (_l == null) { #if UNITY_5 Application.logMessageReceived += this.log; #else Application.RegisterLogCallback(this.log); #endif if (LGameConfig.GetInstance().isDebug) { LuaState.loaderDelegate = loadFileWithSuffix; } else { LuaState.loaderDelegate = loadLuaWithAb; } _l = new LuaSvr(); _l.init(tick, complete); } else { complete(); } }
// Use this for initialization private void Start() { l = new LuaSvr(); l.Init(null, () => { l.Start("valuetype"); }); using (LuaState newState = new LuaState()) { LuaTable table = new LuaTable(newState); Vector2 v2 = new Vector2(1, 2); Vector3 v3 = new Vector3(1, 2, 3); Vector4 v4 = new Vector4(1, 2, 3, 4); Color col = new Color(.1f, .2f, .3f); Foo foo = new Foo(); table["v2"] = v2; table["v3"] = v3; table["v4"] = v4; table["col"] = col; table["foo"] = foo; Assert.IsTrue((Vector2)table["v2"] == v2); Assert.IsTrue((Vector3)table["v3"] == v3); Assert.IsTrue((Vector4)table["v4"] == v4); Assert.IsTrue((Color)table["col"] == col); Assert.IsTrue(table["foo"] == foo); } }
void Start() { luaSvr = new LuaSvr(); luaSvr.init(null, () => { luaSvr.start("useLua"); }, LuaSvrFlag.LSF_DEBUG); }
public void Init() { LuaState.loaderDelegate += LoaderDelegate; l = new LuaSvr(); l.init(null, Complete, LuaSvrFlag.LSF_EXTLIB); DontDestroyOnLoad(this); }
// Use this for initialization private void Start() { l = new LuaSvr(); l.Init(null, () => { l.Start("varobj"); }); }
void Start() { svr = new LuaSvr(); svr.init(null, () => { self = (LuaTable)svr.start("skynet/main"); }, LuaSvrFlag.LSF_EXTLIB); }
//LuaFunction function; void Start() { luaSvr = LuaMgr.GetInstance().Init(); //luaSvr.start("Test"); //luaSvr.init(null, LuaCompleteFunc); LuaCompleteFunc(); }
// Use this for initialization void Start() { luaSvr = new LuaSvr(); luaSvr.init(null, () => { self = (LuaTable)luaSvr.start("startGame"); }); }
// Use this for initialization void Start() { l = new LuaSvr(); l.init(null, () => { l.start("varobj"); }); }
// Use this for initialization void Start() { l = new LuaSvr(); l.init(null, () => { l.start("LuaTest"); }); }
// Use this for initialization void Start() { l = new LuaSvr(); l.init(null, () => { l.start("valuetype"); }); }
// Use this for initialization public void Start() { l = new LuaSvr(); l.Init(null, () => { l.Start("delegate"); }); }
void Awake() { _instance = this; svr = new LuaSvr(); self = (LuaTable)svr.start("LuaFiles/LuaCallCsAPI"); self["event"] = DataEventSource.Instance; self["name"] = "API"; }
private LuaModule() { #if UNITY_EDITOR UnityEngine.Debug.Log("Consturct LuaModule..."); #endif _luaSvr = new LuaSvr(); _luaSvr.init(progress => { }, () => { }); }
public void Start() { c = this; l = new LuaSvr(); l.Init(null, () => { l.Start("custom"); }); }
void Start() { c = this; l = new LuaSvr(); l.init(null, () => { l.start("custom"); }); }
void Start() { c = this; l = new LuaSvr(); l.init(null, () => { l.start("BindCSharp"); }); }
void Start() { luaSvr = new LuaSvr(); LuaSvr.mainState.loaderDelegate += LuaLoader; luaSvr.init(null, () => { luaSvr.start("CreatePrefab.Lua"); }); }
void Start() { svr = new LuaSvr(); svr.init(null, () => { self = (LuaTable)svr.start("circle/circle"); update = (LuaFunction)self["update"]; }); }
// Use this for initialization void Start() { luaSvr = new LuaSvr(); luaSvr.init(null, () => { self = (LuaTable)luaSvr.start("main"); //selfUpdate = (LuaFunction)self["update"]; }); }
void Start() { luaSvr = new LuaSvr(); LuaSvr.mainState.loaderDelegate += LuaLoader; luaSvr.init(null, () => { luaSvr.start("MyPackage.Lua"); }); }
public void ResetStatus() { svr = new LuaSvr(); svr.init(null, () => { CallScript("Main"); save = LuaSvr.mainState.getFunction("save"); }); }
void Start() { luaSvr = new LuaSvr(); LuaSvr.mainState.loaderDelegate += LuaLoader; luaSvr.init(null, () => { luaSvr.start("UseCSharpClass.Lua"); }); }
private void Awake() { LuaSvr svr = new LuaSvr(); svr.init(null, () => { svr.start("06_RequireImport/06_RequireImport"); }); }
public void TestLuaSvr() { var luaSvr = new LuaSvr(); luaSvr.init((x) => { }, () => { }); var code = @" local testVar = 12345; return testVar; "; object ret; luaSvr.luaState.doBuffer(Encoding.UTF8.GetBytes(code), "TestLua", out ret); Assert.AreEqual(ret, 12345); }
public void CreateStructVector2() { var luaSvr = new LuaSvr(); luaSvr.init(x => { }, () => { }); var code = @" local v = Slua.CreateClass('SLua.Test.TestStruct+Vector2', 1, 2) return v "; var ret = luaSvr.luaState.doString(code); Assert.AreEqual(ret, new Vector2(1, 2f)); }
public void TestSLuaLib() { var luaSvr = new LuaSvr(); luaSvr.init(x => { }, () => { }); var code = @" local TestSLua = Slua.GetClass('SLua.Test.TestSLua') return TestSLua "; var ret = luaSvr.luaState.doString(code); Assert.AreEqual("SLua.LuaClassObject", ret.GetType().ToString()); var clsField = ret.GetType().GetField("cls", BindingFlags.NonPublic | BindingFlags.Instance); var cls = clsField.GetValue(ret); Assert.AreEqual(typeof(TestSLua), cls); }
public void Init() { luaSvr = new LuaSvr(); luaSvr.init(x => { }, () => { }); }