Exemplo n.º 1
0
        public static BundleAssetLoader GetLoader(int resourceIndex)
        {
            BundleAssetLoader loader = null;

            s_ResIndexToLoader.TryGetValue(resourceIndex, out loader);
            return(loader);
        }
Exemplo n.º 2
0
        public static BundleAssetLoader GetLoader(string bundleName, string assetName)
        {
            BundleAssetLoader loader = null;
            string            assetKey;

            CalculateAssetKey(bundleName, assetName, out assetKey);
            s_NameToLoader.TryGetValue(assetKey, out loader);
            return(loader);
        }
Exemplo n.º 3
0
        public int LoadAssetSync <T>(string bundleName, string assetName, Action <bool, T> loadedAction) where T : Object
        {
            var assetLoadMode = GameCenter.s_ConfigManager.GlobalGameConfig.AssetLoadMode;

#if UNITY_EDITOR
            if (assetLoadMode == GameConfig.AssetLoadModeEnum.EditMode)
            {
                return(EditorModeAssetLoader.LoadSync(bundleName, assetName, loadedAction));
            }
#endif
            return(BundleAssetLoader.LoadSync(bundleName, assetName, loadedAction));
        }
Exemplo n.º 4
0
        public void UnLoadAsset(int resourceIndex)
        {
            var assetLoadMode = GameCenter.s_ConfigManager.GlobalGameConfig.AssetLoadMode;

#if UNITY_EDITOR
            if (assetLoadMode == GameConfig.AssetLoadModeEnum.EditMode)
            {
                EditorModeAssetLoader.UnLoad(resourceIndex);
            }
            else
#endif
            BundleAssetLoader.UnLoad(resourceIndex);
        }
Exemplo n.º 5
0
        public void OnUpdate()
        {
            if (m_Step == 1)
            {
                if (GameCenter.s_ConfigManager.GlobalGameConfig.LuaScriptLoadMode ==
                    GameConfig.LuaScriptLoadModeEnum.RawFileMode)
                {
                    m_Step = 4;
                }
                else
                {
                    m_Step            = 2;
                    m_LuaFileResIndex = BundleAssetLoader.LoadAsync <LuaFileRef>(
                        CommonDefine.s_ScriptAssetBundleName + "." + CommonDefine.s_BundleSuffixName,
                        CommonDefine.s_ScriptFileDescName, (b, fileRef) =>
                    {
                        m_Step            = 3;
                        var fileBytesDict = new Dictionary <string, ScriptManager.LuaFileBytes>();
                        foreach (var asset in fileRef.AssetsRefDict)
                        {
                            var fileBytes = new ScriptManager.LuaFileBytes();
                            fileBytes.SetBytes(Encoding.UTF8.GetBytes(asset.Value.text));
                            fileBytesDict.Add(asset.Key, fileBytes);
                        }

                        GameCenter.s_ScriptManager.SetLuaFileBytesDict(fileBytesDict);
                    }
                        );
                }
            }
            else if (m_Step == 2)
            {
            }
            else if (m_Step == 3)
            {
                if (m_LuaFileResIndex != -1)
                {
                    BundleAssetLoader.UnLoad(m_LuaFileResIndex);
                }
                m_Step = 4;
            }
            else if (m_Step == 4)
            {
                GameCenter.s_GameFlowManager.GameFlowFsm.ChangeState(GameFlowManager.GameFlowState.LuaLoop);
            }
        }