public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC | LuaSvrFlag.LSF_EXTLIB) { IntPtr L = mainState.L; LuaObject.init(L); #if SLUA_STANDALONE doBind(L); doinit(mainState, flag); complete(); mainState.checkTop(); #else #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { doBind(L); doinit(mainState, flag); complete(); mainState.checkTop(); } else { #endif mainState.lgo.StartCoroutine(doBind(L, tick, () => { doinit(mainState, flag); complete(); mainState.checkTop(); })); #if UNITY_EDITOR } #endif #endif }
public LuaSvr(string main) { luaState = new LuaState(); LuaObject.init(luaState.handle); bind("BindUnity"); bind("BindUnityUI"); bind("BindCustom"); if (LuaDLL.lua_gettop(luaState.handle) != 0) { Debug.LogError("Some function not remove temp value from lua stack."); } GameObject go = new GameObject("LuaSvrProxy"); LuaSvrGameObject lgo = go.AddComponent <LuaSvrGameObject>(); GameObject.DontDestroyOnLoad(go); lgo.state = luaState; luaState.doFile(main); LuaFunction func = (LuaFunction)luaState["main"]; func.call(); }
public LuaSvr(string main) { luaState = new LuaState(); LuaObject.init(luaState.L); bindAll(luaState.L); GameObject go = new GameObject("LuaSvrProxy"); lgo = go.AddComponent <LuaSvrGameObject>(); GameObject.DontDestroyOnLoad(go); lgo.state = luaState; lgo.onUpdate = this.tick; LuaTimer.reg(luaState.L); LuaCoroutine.reg(luaState.L, lgo); Helper.reg(luaState.L); try { LuaDLL.luaS_openextlibs(luaState.L); } catch (Exception) { // do nothing } start(main); if (LuaDLL.lua_gettop(luaState.L) != errorReported) { Debug.LogError("Some function not remove temp value from lua stack. You should fix it."); errorReported = LuaDLL.lua_gettop(luaState.L); } }
public LuaSvr(string main) { luaState = new LuaState(); LuaObject.init(luaState.L); bind("BindUnity"); bind("BindUnityUI"); bind("BindCustom"); bind("BindExtend"); // if you want to extend slua, can implemented BindExtend function like BindCustom etc. GameObject go = new GameObject("LuaSvrProxy"); lgo = go.AddComponent <LuaSvrGameObject>(); GameObject.DontDestroyOnLoad(go); lgo.state = luaState; lgo.onUpdate = this.tick; LuaTimer.reg(luaState.L); LuaCoroutine.reg(luaState.L, lgo); Helper.reg(luaState.L); start(main); if (LuaDLL.lua_gettop(luaState.L) != errorReported) { Debug.LogError("Some function not remove temp value from lua stack. You should fix it."); errorReported = LuaDLL.lua_gettop(luaState.L); } }
public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC) { LuaState luaState = new LuaState(); IntPtr L = luaState.L; LuaObject.init(L); #if SLUA_STANDALONE doBind(L); this.luaState = luaState; doinit(L, flag); complete(); checkTop(L); #else // be caurefull here, doBind Run in another thread // any code access unity interface will cause deadlock. // if you want to debug bind code using unity interface, need call doBind directly, like: // doBind(L); ThreadPool.QueueUserWorkItem(doBind, L); lgo.StartCoroutine(waitForBind(tick, () => { this.luaState = luaState; doinit(L, flag); complete(); checkTop(L); })); #endif }
public void init(Action <int> tick, Action complete, bool debug = false) { LuaState luaState = new LuaState(); IntPtr L = luaState.L; LuaObject.init(L); ThreadPool.QueueUserWorkItem(doBind, L); lgo.StartCoroutine(waitForBind(tick, () => { this.luaState = luaState; doinit(L); if (debug) { lgo.StartCoroutine(waitForDebugConnection(() => { complete(); checkTop(L); })); } else { complete(); checkTop(L); } })); }
public void init( ) { #if !SLUA_STANDALONE if (lgo == null #if UNITY_EDITOR && UnityEditor.EditorApplication.isPlaying #endif ) { GameObject go = new GameObject("LuaSvrProxy"); lgo = go.AddComponent <LuaSvrGameObject>(); GameObject.DontDestroyOnLoad(go); } #endif IntPtr L = luaState.L; LuaObject.init(L); #if SLUA_STANDALONE doBind(L); #else // be caurefull here, doBind Run in another thread // any code access unity interface will cause deadlock. // if you want to debug bind code using unity interface, need call doBind directly, like: // doBind(L); ThreadPool.QueueUserWorkItem(doBind, L); #endif }
static int init(IntPtr L) { LuaObject.init(L); bindAll(L); LuaTimer.reg(L); LuaCoroutine.reg(L, lgo); Helper.reg(L); LuaValueType.reg(L); SLuaDebug.reg(L); LuaDLL.luaS_openextlibs(L); return(0); }
public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC | LuaSvrFlag.LSF_EXTLIB) { IntPtr L = luaState.L; LuaObject.init(L); luaState.lgo.StartCoroutine(doBind(L, tick, () => { doinit(luaState, flag); complete(); luaState.checkTop(); })); }
public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC) { #if !SLUA_STANDALONE if (lgo == null #if UNITY_EDITOR && UnityEditor.EditorApplication.isPlaying #endif ) { GameObject go = new GameObject("LuaSvrProxy"); lgo = go.AddComponent <LuaSvrGameObject>(); GameObject.DontDestroyOnLoad(go); } #endif IntPtr L = luaState.L; LuaObject.init(L); #if SLUA_STANDALONE doBind(L); doinit(L, flag); complete(); checkTop(L); #else // be caurefull here, doBind Run in another thread // any code access unity interface will cause deadlock. // if you want to debug bind code using unity interface, need call doBind directly, like: // doBind(L); #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { doBind(L); doinit(L, flag); complete(); checkTop(L); } else { #endif ThreadPool.QueueUserWorkItem(doBind, L); lgo.StartCoroutine(waitForBind(tick, () => { doinit(L, flag); complete(); checkTop(L); })); #if UNITY_EDITOR } #endif #endif }
public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC) { #if !SLUA_STANDALONE if (lgo == null #if UNITY_EDITOR && UnityEditor.EditorApplication.isPlaying #endif ) { GameObject go = new GameObject("LuaSvrProxy"); lgo = go.AddComponent <LuaSvrGameObject>(); GameObject.DontDestroyOnLoad(go); } #endif IntPtr L = luaState.L; LuaObject.init(L); #if SLUA_STANDALONE doBind(L); doinit(L, flag); complete(); checkTop(L); #else #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { doBind(L); doinit(L, flag); complete(); checkTop(L); } else { #endif lgo.StartCoroutine(doBind(L, tick, () => { doinit(L, flag); complete(); checkTop(L); })); #if UNITY_EDITOR } #endif #endif }
public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC) { #if !SLUA_STANDALONE if (lgo == null && (!SLuaSetting.IsEditor || SLuaSetting.IsPlaying)) { GameObject go = new GameObject("LuaSvrProxy"); lgo = go.AddComponent <LuaSvrGameObject>(); GameObject.DontDestroyOnLoad(go); } #endif IntPtr L = luaState.L; LuaObject.init(L); #if SLUA_STANDALONE doBind(L); doinit(L, flag); complete(); checkTop(L); #else // be caurefull here, doBind Run in another thread // any code access unity interface will cause deadlock. // if you want to debug bind code using unity interface, need call doBind directly, like: // doBind(L); if (SLuaSetting.IsEditor && !SLuaSetting.IsPlaying) { doBind(L); doinit(L, flag); complete(); checkTop(L); } else { lgo.StartCoroutine(doBind(L, tick, () => { doinit(L, flag); complete(); checkTop(L); })); } #endif }
public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC | LuaSvrFlag.LSF_EXTLIB) { IntPtr L = mainState.L; LuaObject.init(L); if (SLuaSetting.IsEditor && !SLuaSetting.IsPlaying) { doBind(L); doinit(mainState, flag); complete(); mainState.checkTop(); } else { mainState.lgo.StartCoroutine(doBind(L, tick, () => { doinit(mainState, flag); complete(); mainState.checkTop(); })); } }
public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC, bool useTick = true) { LuaState luaState = new LuaState(); IntPtr L = luaState.L; LuaObject.init(L); //#if SLUA_STANDALONE doBind(L); //LuaDLL.init_profiler(L); this.luaState = luaState; doinit(L, flag, useTick); if (complete != null) { complete(); } checkTop(L); //#else // be caurefull here, doBind Run in another thread // any code access unity interface will cause deadlock. // if you want to debug bind code using unity interface, need call doBind directly, like: //doBind(L); // ThreadPool.QueueUserWorkItem(doBind, L); // lgo.StartCoroutine(waitForBind(tick, () => // { // this.luaState = luaState; // doinit(L,flag); // complete(); // checkTop(L); // })); //#endif }