Inheritance: LuaFileUtils
Esempio n. 1
0
    public void Reset()
    {
        _GameLuaIsLoaded = false;
        if (luaState != null)
        {
            luaState.Dispose();
        }
        if (loop != null)
        {
            Destroy(loop);
            loop = null;
        }
        if (loader != null)
        {
            loader.Dispose();
            loader = null;
        }
//        if(manager)
//        {
//            Destroy(manager);
//            manager = null;
//        }

        Initialize();
        StartLooper();
        StartManager();
    }
Esempio n. 2
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);
    }
Esempio n. 3
0
    // 更新检查完成
    void OnDownloadFinish()
    {
        UpdateManager.Instance.UpdateVersion();

        AssetBundleManager.InitDependenceInfo();

        ResourceManager.Instance.Init();

        LanguageManager.GetInstance().Init();

        CfgManager.GetInstance().Init();

        // 初始化lua engine
        LuaFileUtils loader = new LuaResLoader();

        loader.beZip = GameConfig.EnableUpdate;         // 是否读取assetbundle lua文件
        Dictionary <string, string> localfiles = UpdateManager.Instance.LocalFiles;

        foreach (string file in localfiles.Keys)
        {
            if (file.Substring(0, 3) == "lua")
            {
                AssetBundle assetBundle = AssetBundleManager.GetAssetBundle(file);
                string      name        = Path.GetFileNameWithoutExtension(file);
                LuaFileUtils.Instance.AddSearchBundle(name, assetBundle);
            }
        }

        //
        LuaManager luaManager = LuaManager.Instance;

        luaManager.InitStart();
        luaManager.DoFile("Game");
        Util.CallMethod("Game", "OnInitOK");
    }
Esempio n. 4
0
    // Use this for initialization

    public void Init()
    {
        m_luaResLoader = new LuaResLoader();
        m_luaState     = new LuaState();
        InitLuaPath();
        m_luaState.Start();
        LuaBinder.Bind(m_luaState);
    }
Esempio n. 5
0
        public void Restart()
        {
//#if !UNITY_EDITOR
//            instance = this;
//#else
            instance = new LuaResLoader(); //this;
//#endif
        }
Esempio n. 6
0
        void Awake()
        {
//#if UNITY_EDITOR
            //    instance = this;
//#else
            instance = new LuaResLoader();  //this;
//#endif
        }
Esempio n. 7
0
 public override void Dispose()
 {
     if (instance != null)
     {
         instance = null;
         base.Dispose();
     }
 }
Esempio n. 8
0
 protected void Init()
 {
     luaLoader = new LuaResLoader();
     luaState  = new LuaState(luaLoader.ReadFile);
     OpenLibs();
     luaState.LuaSetTop(0);
     Bind();
     LoadLuaFiles();
 }
Esempio n. 9
0
        public override void OnInit()
        {
            luaResLoader = new LuaResLoader();
            lua          = new LuaState(luaResLoader.ReadFile);
            //this.OpenLibs();
            lua.LuaSetTop(0);

            LuaBinder.Bind(lua);

            luaResLoader.LoadluaChunks();

            this.lua.Start();                //启动LUAVM
            DelegateFactory.Init();

            this.StartMain();
        }
Esempio n. 10
0
 public override void OnDestroy()
 {
     _GameLuaIsLoaded = false;
     if (luaState != null)
     {
         luaState.Dispose();
     }
     if (loop != null)
     {
         Destroy(loop);
         loop = null;
     }
     if (loader != null)
     {
         loader.Dispose();
         loader = null;
     }
 }
Esempio n. 11
0
    private MsgHandler()
    {
        LuaResLoader loader = new LuaResLoader();

        string luaPersistentPath = AppConst.PERSISTENT_PATH + "/lua";

        string[] luaList = Directory.GetFiles(luaPersistentPath);
        for (int i = 0; i < luaList.Length; ++i)
        {
            if (luaList[i].EndsWith(AppConst.AB_EXT_NAME))
            {
                AssetBundle luaAB = AssetBundle.LoadFromFile(luaList[i]);
                if (null != luaAB)
                {
                    loader.AddSearchBundle(Path.GetFileNameWithoutExtension(luaList[i]), luaAB);
                    Debug.Log("lua res loader add search bundle ok:" + Path.GetFileNameWithoutExtension(luaList[i]));
                }
                else
                {
                    Debug.LogError("Load lua AB file error:" + luaList[i]);
                }
            }
        }
    }
Esempio n. 12
0
    protected override LuaFileUtils InitLoader()
    {
        LuaResLoader ret = new LuaResLoader();

        return(ret);
    }