Esempio n. 1
0
        public IEnumerator Load(MonoBehaviour mb)
        {
            _index.Clear();

            AssetIndexFile indexP = new AssetIndexFile();

            yield return(mb.StartCoroutine(LoadImpl(GameConfig.DATA_URL + "media/file.list", AssetInfo.STORAGE_STREAMING, _index)));

            yield return(mb.StartCoroutine(LoadImpl(GameConfig.PERSISTENT_URL + "media/file.list", AssetInfo.STORAGE_PERSISTEN, indexP)));

            // 流数据文件版本更高,例如直接安装了app新版本
            if (indexP.GetVersion() == 0 || _index.GetVersion() > indexP.GetVersion())
            {
                yield break;
            }

            // 逐个比较文件索引,判定使用哪个文件
            _index.SetVersion(indexP.GetVersion());
            foreach (var asset in indexP.FetchAll())
            {
                if (asset == null)
                {
                    continue;
                }

                // 文件不存在或有差异则用PERSISTEN的条目覆盖
                AssetInfo old = _index.GetAssetInfo(asset.hash);
                if (old == null || old.IsDiff(asset))
                {
                    _index.AddAssetInfo(asset);
                }
            }
        }
Esempio n. 2
0
 public int GetVersion()
 {
     return(_index.GetVersion());
 }