コード例 #1
0
ファイル: LuaSvr.cs プロジェクト: kun123456765/slua
        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);
                }
            }));
        }
コード例 #2
0
        public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC)
        {
            LuaState luaState = new LuaState();

            IntPtr L = luaState.L;

            LuaObject.init(L);
            lgo.openDebug = (flag & LuaSvrFlag.LSF_DEBUG) != 0;

            // 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);
                if (lgo.openDebug)
                {
                    lgo.StartCoroutine(waitForDebugConnection(() =>
                    {
                        complete();
                        checkTop(L);
                    }));
                }
                else
                {
                    complete();
                    checkTop(L);
                }
            }));
        }
コード例 #3
0
        public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_3RDDLL)
        {
            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
        }
コード例 #4
0
        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
        }
コード例 #5
0
        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
        }
コード例 #6
0
ファイル: LuaSvr.cs プロジェクト: youmuren0613/Cs2Lua
        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
        }