示例#1
0
        public IEnumerator StartLuaSvr(Action <bool> onComplete)
        {
            if (ResourceManager.Instance.State != ResourceManager.RMState.AssetBundleManifestLoadEnd)
            {
                global::Debug.LogError("StartLuaSvr fail ResourceManager not ready");
                onComplete(false);
                yield break;
            }
            string      initModulePath  = this.GetModulePath(this.m_luaInitModuleName);
            TextAsset   initModuleAsset = null;
            IEnumerator iter            = ResourceManager.Instance.LoadAsset <TextAsset>(initModulePath, delegate(string lpath, TextAsset lasset)
            {
                initModuleAsset = lasset;
            }, false, false);

            yield return(iter);

            if (initModuleAsset == null)
            {
                global::Debug.LogError("StartLuaSvr fail load initModuleAsset fail");
                onComplete(false);
                yield break;
            }
            ResourceManager.Instance.MakeAssetBundleDontUnload(initModulePath);
            this.m_luaSvr = new LuaSvr();
            LuaSvr.mainState.loaderDelegate = new LuaState.LoaderDelegate(this.LuaLoader);
            this.m_luaSvr.init(null, delegate
            {
                if (!string.IsNullOrEmpty(this.m_luaInitModuleName))
                {
                    this.m_luaSvr.start(this.m_luaInitModuleName);
                }
                this.m_luaProtoBufExtensionHandler = LuaProtoBufExtensionHandler.Create();
                DummyType.InitLuaModule(LuaSvr.mainState);
            }, LuaSvrFlag.LSF_EXTLIB);
            onComplete(true);
            yield break;
        }