Register() public static méthode

public static Register ( LuaState, state, MonoBehaviour behaviour ) : void
state LuaState,
behaviour MonoBehaviour
Résultat void
Exemple #1
0
 protected virtual void OnLoadFinished()
 {
     luaState.Start();
     LuaCoroutine.Register(luaState, this);
     StartLooper();
     StartMain();
 }
Exemple #2
0
 protected virtual void Bind()
 {
     LuaBinder.Bind(luaState);
     ColaLuaExtension.Register(luaState);
     DelegateFactory.Init();
     LuaCoroutine.Register(luaState, this);
 }
Exemple #3
0
        //初始化
        private void init()
        {
//			if (mLuaState != null) {
//				mLuaState.Dispose ();
//			}
                        #if UNITY_EDITOR
            LuaFileUtils.Instance.beZip = UseAssetBundleLuaInEditor;
                        #else
            LuaFileUtils.Instance.beZip = true;
                        #endif
            mLuaState       = new LuaState();
            mLuaState.LogGC = false;
            mLuaState.Start();
            LuaBinder.Bind(mLuaState);
            mLuaState.DoFile(LuaFileUtils.Instance.beZip?LuaEnterFile:LuaEnterDebugFile);

            //协程
            luaCoroutine = GameObject.Find("LuaCoroutine");
            if (luaCoroutine == null)
            {
                luaCoroutine = new GameObject();
                luaCoroutine.gameObject.name = "LuaCoroutine";
                luaCoroutine.AddComponent <LuaCoroutineComponent> ();
                UnityEngine.Object.DontDestroyOnLoad(luaCoroutine);
            }
            LuaCoroutine.Register(mLuaState, luaCoroutine.GetComponent <LuaCoroutineComponent>());

            addFunc(FuncName.createLuaFile);
        }
Exemple #4
0
    void Start()
    {
        lua = new LuaState();
        lua.OpenLibs(LuaDLL.luaopen_pb);
        lua.OpenLibs(LuaDLL.luaopen_bit);
        lua.OpenLibs(LuaDLL.luaopen_lpeg);
        lua.OpenLibs(LuaDLL.luaopen_socket_core);
        lua.LuaSetTop(0);

        LuaBinder.Bind(lua);
        DelegateFactory.Init();
        LuaCoroutine.Register(lua, this);

        lua.AddSearchPath(Application.dataPath + "/Lua");
        lua.AddSearchPath(Application.dataPath + "/ToLua/Lua");

        lua.Start();

        lua.DoFile("Main.lua");

        LuaFunction start = lua.GetFunction("main");

        start.Call("params");
        start.Dispose();
        start = null;

        tickFunc      = lua.GetFunction("tickFunc");
        fixedTickFunc = lua.GetFunction("fixedTickFunc");

        m_LastUpdateShowTime = Time.realtimeSinceStartup;
    }
Exemple #5
0
    /// <summary>
    /// 自定义解析的初始化
    /// </summary>
    public void Init()
    {
        //激活自定义解析器,最后打包的时候再用
        //new LuaCustomLoader();


        //初始化唯一的LuaState
        luaState = new LuaState();
        luaState.Start();

        //委托初始化 委托工厂初始化 想要C#和Lua相互访问使用委托 必须先初始化工厂 否则没办法使用
        DelegateFactory.Init();

        //协程相关
        //如果想让tolua协程跑起来 必须加一个函数
        LuaLooper luaLooper = this.gameObject.AddComponent <LuaLooper>();

        //将我们自己声明的解析器和lualoop绑定起来
        luaLooper.luaState = luaState;

        //Lua协程注册
        LuaCoroutine.Register(luaState, this);

        //Lua使用unity中的相关类 绑定Lua解析器
        LuaBinder.Bind(luaState);
    }
Exemple #6
0
        // Use this for initialization
        public void TestStart()
        {
            //GameObject.DontDestroyOnLoad(gameObject);
            new LuaResLoader();
            lua = new LuaState();

            this.OpenLibs();            //这里是添加调试luaide
            lua.LuaSetTop(0);

            float t = Time.realtimeSinceStartup;

            LuaBinder.Bind(lua);
            Debug.Log("LuaBinder Wrap注册:" + (Time.realtimeSinceStartup - t) + "s");

            LuaCoroutine.Register(lua, this);            //携程

            DelegateFactory.Init();
            lua.Start();

            string fullPath = Application.dataPath + "/FXGame/Lua";

            lua.AddSearchPath(fullPath);
            fullPath = Application.dataPath + "/FXGame/ToLua/Lua";
            lua.AddSearchPath(fullPath);

            StartMain();
            StartLooper();//这里是处理update的方法,不调用这里计时器执行一次
        }
Exemple #7
0
        public void Reload()
        {
            Debug.LogError("00_Reload");
            if (m_LuaState != null)
            {
                m_LuaState.Dispose();
                m_LuaState = null;
            }

            if (m_LuaLooper != null)
            {
                m_LuaLooper.Destroy();
            }

            m_LuaState = new LuaState();
            //m_LuaState.InitPackagePath();
            this.OpenLibs();
            m_LuaState.LuaSetTop(0);

            LuaBinder.Bind(m_LuaState);
            LuaCoroutine.Register(m_LuaState, this);

            m_LuaLoader.Restart();

            // m_LuaState.AddSearchPath(Application.dataPath + "/Lua");

#if UNITY_EDITOR
            if (!LuaConst.USE_AB)
            {
                m_LuaState.AddSearchPath(LuaConst.toluaDir);
                m_LuaState.AddSearchPath(LuaConst.luaDir);
            }
#endif
        }
Exemple #8
0
    void Initialize()
    {
        luaState = new LuaState();
        loader   = new LuaResLoader();
#if UNITY_EDITOR
        luaState.AddSearchPath(LuaConst.luaDir);
#endif
#if AB_MODE
        luaState.AddSearchPath(AssetBundleUtility.LocalAssetBundlePath);
        luaState.AddSearchPath(AssetBundleUtility.GetStreamingPath());
#endif
        luaState.OpenLibs(LuaDLL.luaopen_pb);
        //if (LuaConst.openLuaSocket)
        //{
        //    OpenLuaSocket();
        //}

        //if (LuaConst.openZbsDebugger)
        //{
        //    OpenZbsDebugger();
        //}
        luaState.LuaSetTop(0);
        LuaBinder.Bind(luaState);
        luaState.Start();
        LuaCoroutine.Register(luaState, this);
    }
Exemple #9
0
        void Awake()
        {
            mInst = this;

            lua = new LuaState();
            // 初始化加载第三方库
            lua.OpenLibs(LuaDLL.luaopen_pb);
            lua.OpenLibs(LuaDLL.luaopen_sproto_core);
            lua.OpenLibs(LuaDLL.luaopen_protobuf_c);
            lua.OpenLibs(LuaDLL.luaopen_lpeg);
            lua.OpenLibs(LuaDLL.luaopen_bit);
            lua.OpenLibs(LuaDLL.luaopen_socket_core);

            //cjson 比较特殊,只new了一个table,没有注册库,这里注册一下
            lua.LuaGetField(LuaIndexes.LUA_REGISTRYINDEX, "_LOADED");
            lua.OpenLibs(LuaDLL.luaopen_cjson);
            lua.LuaSetField(-2, "cjson");
            lua.OpenLibs(LuaDLL.luaopen_cjson_safe);
            lua.LuaSetField(-2, "cjson.safe");
            lua.LuaSetTop(0);

            LuaBinder.Bind(lua);
            DelegateFactory.Init();
            LuaCoroutine.Register(lua, this);
        }
 void Awake()
 {
     Instance = this;
     luaState = new LuaState();
     luaState.OpenLibs(LuaDLL.luaopen_pb);
     LuaBinder.Bind(luaState);
     LuaCoroutine.Register(luaState, this);
 }
Exemple #11
0
 public override void Initialize()
 {
     luaState = new LuaState();
     OpenLibs();
     luaState.LuaSetTop(0);
     LuaBinder.Bind(luaState);
     LuaCoroutine.Register(luaState, App.Instance);
 }
Exemple #12
0
 // Use this for initialization
 void Awake()
 {
     loader = new LuaLoader();
     lua    = new LuaState();
     this.InitLuaLibrary();
     LuaBinder.Bind(lua);
     LuaCoroutine.Register(lua, this);
 }
Exemple #13
0
 public override void Load(params object[] _Agr)
 {
     lua.LuaSetTop(0);
     LuaBinder.Bind(lua);
     OpenLibs();
     DelegateFactory.Init();
     LuaCoroutine.Register(lua, Manager_ManagerModel.Instance);
     base.Load(_Agr);
 }
Exemple #14
0
    // Use this for initialization
    void Awake()
    {
        lua = new LuaState();
        this.OpenLibs();
        lua.LuaSetTop(0);

        LuaBinder.Bind(lua);
        LuaCoroutine.Register(lua, this);
    }
Exemple #15
0
 private void Awake()
 {
     this.loader = new LuaLoader();
     this.lua    = new LuaState();
     this.OpenLibs();
     this.lua.LuaSetTop(0);
     LuaBinder.Bind(this.lua);
     LuaCoroutine.Register(this.lua, this);
 }
Exemple #16
0
        void Awake()
        {
            state = new LuaState();
            OpenLibs();
            state.LuaSetTop(0);

            LuaBinder.Bind(state);
            DelegateFactory.Init();
            LuaCoroutine.Register(state, this);
        }
Exemple #17
0
 // Use this for initialization
 void Awake()
 {
     loader = new LuaLoader();
     lua    = new LuaState();
     this.OpenLibs();
     lua.LuaSetTop(0);
     KBELuaUtil.SetCallLuaFunction(this.CallFunction);
     LuaBinder.Bind(lua);
     LuaCoroutine.Register(lua, this);
 }
 void IStartRunner.Start()
 {
     GameLuaFileUtils.Start();
     LuaManager.Init();
     _luaState = LuaManager.luaState;
     OpenLibs();
     _luaState.LuaSetTop(0);
     LuaCoroutine.Register(_luaState, CoroutineManager.longLive.behavior);
     ThreadSystem.RunAysn(Bind);
 }
Exemple #19
0
 // 初始化环境
 private void InitLuaEnv()
 {
     m_LuaState = new LuaState();
     OpenLibs();
     m_LuaLoader = new LuaLoader();
     m_LuaState.LuaSetTop(0);
     LuaBinder.Bind(m_LuaState);
     DelegateFactory.Init();
     LuaCoroutine.Register(m_LuaState, this);
 }
Exemple #20
0
        void Awake()
        {
            m_lua = new LuaState();
            this.OpenLibs();
            m_lua.LuaSetTop(0);

            LuaBinder.Bind(m_lua);
            DelegateFactory.Init();
            LuaCoroutine.Register(m_lua, this);
        }
Exemple #21
0
    public void InitLua()
    {
        lua = new LuaState();
        this.OpenLibs();

        lua.LuaSetTop(0);
        LuaBinder.Bind(lua);
        DelegateFactory.Init();
        LuaCoroutine.Register(lua, this);
        lua.Start();
    }
Exemple #22
0
        // Use this for initialization
        void Awake()
        {
            loader = new LuaLoader();
            lua    = new LuaState();   //创建tolua提供的LuaState对象
            this.OpenLibs();
            lua.LuaSetTop(0);

            LuaBinder.Bind(lua);       //Lua - C# 中间层Wrap文件分别向虚拟机注册自己
            DelegateFactory.Init();
            LuaCoroutine.Register(lua, this);
        }
 protected override void AwakeEx()
 {
     base.AwakeEx();
     loader = new LuaLoaderHelper();
     lua    = new LuaState();
     OpenLibs();
     lua.LuaSetTop(0);
     LuaBinder.Bind(lua);
     DelegateFactory.Init();
     LuaCoroutine.Register(lua, this);
 }
Exemple #24
0
        /// <summary>
        ///
        /// </summary>
        public override void Init()
        {
            this._loader = new LuaLoader();
            this._lua    = new LuaState();
            this.OpenLibs();
            this._lua.LuaSetTop(0);

            LuaBinder.Bind(this._lua);
            DelegateFactory.Init();
            LuaCoroutine.Register(this._lua, this);
        }
Exemple #25
0
        // Use this for initialization
        void Awake()
        {
            loader = new GameLuaLoader();
            lua    = new LuaState();
            this.OpenLibs();
            lua.LuaSetTop(0);

            LuaBinder.Bind(lua);
            DelegateFactory.Init();
            LuaCoroutine.Register(lua, this);
        }
Exemple #26
0
        // Use this for initialization
        void Awake()
        {
            DontDestroyOnLoad(this);
            loader = new LuaLoader();
            lua    = new LuaState();
            this.OpenLibs();
            lua.LuaSetTop(0);

            LuaBinder.Bind(lua);
            LuaCoroutine.Register(lua, this);
        }
Exemple #27
0
 protected override void AwakeEx()
 {
     base.AwakeEx();
     //初始化LuaMgr;
     loader = new LuaLoaderHelper();//TODO:Lua AssetBundle的使用;
     lua = new LuaState();
     this.OpenLibs();
     lua.LuaSetTop(0);
     LuaBinder.Bind(lua);
     DelegateFactory.Init();
     LuaCoroutine.Register(lua, this);
 }
Exemple #28
0
        public void Init()
        {
            m_FileList = new HashSet <string>();

            m_Lua    = new LuaState();
            m_Loader = new LuaLoader();
            this.OpenLibs();
            m_Lua.LuaSetTop(0);

            LuaBinder.Bind(m_Lua);
            LuaCoroutine.Register(m_Lua, this);
        }
Exemple #29
0
    void Awake()
    {
        DontDestroyOnLoad(gameObject);
        instance = this;

        LuaState = new LuaState();
        this.OpenLibs();
        LuaState.LuaSetTop(0);

        LuaBinder.Bind(LuaState);
        LuaCoroutine.Register(LuaState, this);
    }
Exemple #30
0
        // Use this for initialization
        void Awake()
        {
            Instance = this;
            loader   = new LuaLoader();
            lua      = new LuaState();
            this.OpenLibs();
            lua.LuaSetTop(0);

            LuaBinder.Bind(lua);
            LuaCoroutine.Register(lua, this);
            InitStart();
        }