/// <summary> /// 读取资源的缓存策略 /// </summary> void ReadResourceCacheConfig() { string cachePath = "Config/CacheConfig/need_cache_list"; TextAsset needCacheListAsset = XResource.LoadAsset <TextAsset>(cachePath); TextAsset needPersistListAsset = XResource.LoadAsset <TextAsset>("Config/CacheConfig/need_persist_list"); if (needCacheListAsset != null) { string configText = StringUtility.UTF8BytesToString(needCacheListAsset.bytes); if (!LoadCacheAndTimeConfig(configText)) { BLogger.Warning("-------------LoadCacheAndTimeConfig failed: {0}", cachePath); } } else { BLogger.Error("read need cache resource list config failed"); } if (needPersistListAsset != null) { List <string> needPersistList = AssetBundleUtil.ReadTextStringList(needPersistListAsset.bytes); if (needPersistList != null) { XResource.RegPersistResPath(needPersistList); BLogger.Info("-------------register need persist res list: {0}", needPersistList.Count); } } else { BLogger.Error("read need persist resource list config failed"); } }
public UnityEngine.Object LoadResourceAsset(string path, Type type, bool logNotFound) { if (type == null) { BLogger.Fatal("Invalid asset type"); return(null); } LoadFromType loadFromType; return(XResource.LoadAsset(path, type, out loadFromType, logNotFound)); }
/// <summary> /// 读取ab缓存的配置 /// </summary> /// <returns></returns> private bool LoadAbCacheConfig() { TextAsset needPersistAsset = XResource.LoadAsset <TextAsset>("Config/AbConfig/need_persist_assetbundle"); if (needPersistAsset == null) { BLogger.Error("read resource failed: {0}", "need_persist_assetbundle"); return(false); } List <string> listAbPath = AssetBundleUtil.ReadTextStringList(needPersistAsset.bytes); List <string> listMd5Path = new List <string>(); foreach (string abPath in listAbPath) { listMd5Path.Add(AssetBundleUtil.GetPathHash(abPath)); } AssetBundlePool.Instance.RegPersistAssetBundlePath(listMd5Path); //Logger.Error("regist persist assetbundle count: {0}", listMd5Path.Count); return(true); }