Exemplo n.º 1
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);

            #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
        }
Exemplo n.º 2
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
                )
            {
                lgo = new LuaSvrGameObject[luaState.Length];
                for (int n = 0; n < luaState.Length; n++)
                {
                    GameObject go = new GameObject("LuaStateProxy_" + n);
                    lgo[n] = go.AddComponent <LuaSvrGameObject>();
                    GameObject.DontDestroyOnLoad(go);
                }
            }
#endif
            for (int n = 0; n < luaState.Length; n++)
            {
                IntPtr L = luaState[n].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[n].StartCoroutine(waitForBind(tick, () =>
                //                    {
                //                        doinit(L, flag);
                //                        complete();
                //                        checkTop(L);
                //                    }));
                //#if UNITY_EDITOR
                //                }
                //#endif
                //#endif
            }
        }
Exemplo n.º 3
0
        // 必须在绑定完成后调用
        public void onBindComplete(Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC | LuaSvrFlag.LSF_EXTLIB)
        {
            // lua状态
            IntPtr L = this.luaState.L;

            doinit(L, flag);
            complete();
            checkTop(L);
        }
Exemplo n.º 4
0
 public void reset(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC)
 {
     LuaTimer.delAll();
     for (int n = 0; n < luaState.Length; n++)
     {
         luaState[n].Close();
         luaState[n] = new LuaState();
     }
     init(tick, complete, flag);
 }
Exemplo n.º 5
0
 public void reset(Action<int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC)
 {
     LuaTimer.delAll();
     for (int i = 0; i < this.luaState.Length; i++)
     {
         this.luaState[i].Close();
         this.luaState[i] = new LuaState();
     }
     this.init(tick, complete, flag);
 }
Exemplo n.º 6
0
    /**
     * Initialize lua environment.
     *
     * @param Action<int> cProgress - The callback event for bind each C# classes, datatypes and functions. The parameter 'int' indicates the current progress.
     * @param Action cComplete - The callback event when all binding have beening completed.
     * @param LuaSvrFlag eFlag - The slua init flag, can be combined.
     * @return bool - true if lua can be initialized, otherwise false.
     */
    public bool Initialize(Action <int> cProgress, Action cComplete, LuaSvrFlag eFlag = LuaSvrFlag.LSF_BASIC)
    {
        if (null == cComplete)
        {
            Debug.LogError("You should give a lua bind complete delegate!");
            return(false);
        }

        init(cProgress, () => { OnBindLuaComplete(); cComplete(); }, eFlag);
        return(true);
    }
Exemplo n.º 7
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();
            }));
        }
Exemplo n.º 8
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
        }
Exemplo n.º 9
0
        protected void doinit(LuaState L, LuaSvrFlag flag)
        {
            L.openSluaLib();
            if ((flag & LuaSvrFlag.LSF_EXTLIB) != 0)
            {
                L.openExtLib();
            }

            if ((flag & LuaSvrFlag.LSF_3RDDLL) != 0)
            {
                Lua3rdDLL.open(L.L);
            }
        }
Exemplo n.º 10
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
        }
Exemplo n.º 11
0
        protected void DoInit(LuaState state, LuaSvrFlag flag)
        {
            state.OpenLibrary();
            LuaValueType.Register(state.StatePointer);

            if ((flag & LuaSvrFlag.LSF_EXTLIB) != 0)
            {
                state.OpenExternalLibrary();
            }

            if ((flag & LuaSvrFlag.LSF_3RDDLL) != 0)
            {
                Lua3rdDLL.Open(state.StatePointer);
            }
        }
Exemplo n.º 12
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
        }
Exemplo n.º 13
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);

#if SLUA_STANDALONE
            doBind(L);
            this.luaState = luaState;
            doinit(L, flag);
            complete();
            checkTop(L);
#else
            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);
                }
            }));
#endif
        }
Exemplo n.º 14
0
        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
        }
Exemplo n.º 15
0
 public void init(Action<int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_BASIC)
 {
     if (LuaSvr.lgo == null)
     {
         LuaSvr.lgo = new LuaSvrGameObject[this.luaState.Length];
         for (int i = 0; i < this.luaState.Length; i++)
         {
             GameObject gameObject = new GameObject("LuaStateProxy_" + i);
             LuaSvr.lgo[i] = gameObject.AddComponent<LuaSvrGameObject>();
             UnityEngine.Object.DontDestroyOnLoad(gameObject);
         }
     }
     for (int j = 0; j < this.luaState.Length; j++)
     {
         IntPtr l = this.luaState[j].L;
         LuaObject.init(l);
         this.doBind(l);
         this.doinit(l, flag);
         complete();
         this.checkTop(l);
     }
 }
Exemplo n.º 16
0
        protected void doinit(IntPtr L, LuaSvrFlag flag)
        {
                        #if !SLUA_STANDALONE
            LuaTimer.reg(L);
                        #if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlaying)
                        #endif
            LuaCoroutine.reg(L, lgo);
                        #endif
            Lua_SLua_ByteArray.reg(L);
            Helper.reg(L);
            LuaValueType.reg(L);
            if ((flag & LuaSvrFlag.LSF_EXTLIB) != 0)
            {
                LuaDLL.luaS_openextlibs(L);
                LuaSocketMini.reg(L);
            }

            if ((flag & LuaSvrFlag.LSF_3RDDLL) != 0)
            {
                Lua3rdDLL.open(L);
            }

                        #if !SLUA_STANDALONE
                        #if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlaying)
            {
                        #endif
            lgo.state    = luaState;
            lgo.onUpdate = this.tick;
            lgo.init();
                        #if UNITY_EDITOR
        }
                        #endif
                        #endif

            inited = true;
        }
Exemplo n.º 17
0
        void doinit(IntPtr L, LuaSvrFlag flag)
        {
#if !SLUA_STANDALONE
            LuaTimer.reg(L);
#if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlaying)
#endif
            LuaCoroutine.reg(L, lgo[0]);
#endif
            Helper.reg(L);
            LuaValueType.reg(L);

//            if ((flag & LuaSvrFlag.LSF_EXTLIB) != 0)
            LuaDLL.puaS_openextlibs(L);
            if ((flag & LuaSvrFlag.LSF_3RDDLL) != 0)
            {
                Lua3rdDLL.open(L);
            }

#if !SLUA_STANDALONE
#if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlaying)
            {
#endif

            for (int n = 0; n < luaState.Length; n++)
            {
                lgo[n].state    = luaState[n];
                lgo[n].onUpdate = this.tick;
                lgo[n].init();
            }
#if UNITY_EDITOR
        }
#endif
#endif

            inited = true;
        }
Exemplo n.º 18
0
        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();
                }));
            }
        }
Exemplo n.º 19
0
        private void _doinit(IntPtr _luaState, LuaSvrFlag _flag)
        {
            //LuaTimer.reg( _luaState );
#if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlaying)
#endif
            LuaCoroutine.reg(_luaState, this);
            SLua.Helper.reg(_luaState);
            if (SLuaSetting.Instance.useLuaValueType)
            {
                LuaValueType.reg(_luaState);
            }

            if ((_flag & LuaSvrFlag.LSF_EXTLIB) != 0)
            {
                LuaDLL.luaS_openextlibs(_luaState);
            }
            if ((_flag & LuaSvrFlag.LSF_3RDDLL) != 0)
            {
                Lua3rdDLL.open(_luaState);
            }

            Inited = true;
        }
Exemplo n.º 20
0
        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
        }
Exemplo n.º 21
0
        void doinit(IntPtr L,LuaSvrFlag flag)
        {
            #if !SLUA_STANDALONE
            LuaTimer.reg(L);
            LuaCoroutine.reg(L, lgo);
            #endif
            Helper.reg(L);
            LuaValueType.reg(L);

            if((flag&LuaSvrFlag.LSF_EXTLIB)!=0)
                LuaDLL.luaS_openextlibs(L);
            if((flag&LuaSvrFlag.LSF_3RDDLL)!=0)
                Lua3rdDLL.open(L);

            #if !SLUA_STANDALONE
            lgo.state = luaState;
            lgo.onUpdate = this.tick;
            lgo.init();
            #endif

            inited = true;
        }
Exemplo n.º 22
0
        void doinit(IntPtr L,LuaSvrFlag flag)
        {
            LuaTimer.reg(L);
            LuaCoroutine.reg(L, lgo);
            Helper.reg(L);
            LuaValueType.reg(L);
            if((flag&LuaSvrFlag.LSF_DEBUG)!=0)
                SLuaDebug.reg(L);
            if((flag&LuaSvrFlag.LSF_EXTLIB)!=0)
                LuaDLL.luaS_openextlibs(L);
            if((flag&LuaSvrFlag.LSF_3RDDLL)!=0)
                Lua3rdDLL.open(L);

            lgo.state = luaState;
            lgo.onUpdate = this.tick;
            lgo.init();

            inited = true;
        }
Exemplo n.º 23
0
        private Action <IntPtr>[] getBindList(Assembly assembly, string ns) => default;        // 0x00C9DEB0-0x00C9E020

        protected void doinit(IntPtr L, LuaSvrFlag flag)
        {
        }                                                           // 0x00C9E020-0x00C9E1F0
Exemplo n.º 24
0
        void doinit(IntPtr L,LuaSvrFlag flag)
        {
            #if !SLUA_STANDALONE
            LuaTimer.reg(L);
            LuaCMDHelper.reg(L);
            #if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlaying)
            #endif
            LuaCoroutine.reg(L, lgo);
            #endif
            Helper.reg(L);
            LuaValueType.reg(L);

            if((flag&LuaSvrFlag.LSF_EXTLIB)!=0)
                LuaDLL.luaS_openextlibs(L);
            if((flag&LuaSvrFlag.LSF_3RDDLL)!=0)
                Lua3rdDLL.open(L);

            #if !SLUA_STANDALONE
            #if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlaying)
            {
            #endif
            lgo.state = luaState;
            lgo.onUpdate = this.tick;
            lgo.init();
            #if UNITY_EDITOR
            }

            #endif
            #endif

                inited = true;
        }
Exemplo n.º 25
0
        }                                            // 0x00C9F3F0-0x00C9F4D0

        public void init(Action <int> tick, Action complete, LuaSvrFlag flag = LuaSvrFlag.LSF_EXTLIB /* Metadata: 0x00613F35 */)
        {
        }                                                    // 0x00C9F4D0-0x00C9F6E0
Exemplo n.º 26
0
    /**
     * Initialize lua environment.
     *
     * @param Action<int> cProgress - The callback event for bind each C# classes, datatypes and functions. The parameter 'int' indicates the current progress.
     * @param Action cComplete - The callback event when all binding have beening completed.
     * @param LuaSvrFlag eFlag - The slua init flag, can be combined.
     * @return bool - true if lua can be initialized, otherwise false.
     */
    public bool Initialize(Action<int> cProgress, Action cComplete, LuaSvrFlag eFlag = LuaSvrFlag.LSF_BASIC)
    {
        if (null == cComplete)
        {
            Debug.LogError("You should give a lua bind complete delegate!");
            return false;
        }

        init(cProgress, () => {OnBindLuaComplete(); cComplete();}, eFlag);
        return true;
    }