private void downloadComplete() { StopAllCoroutines(); SALang.MakDirValid(SAAppConfig.RemotePath); convertXML.Save(Path.Combine(SAAppConfig.RemotePath, MD5_NAME));//写入本地最新XML version = newVersion; //资源缓存 SACache.LoadLuaPackage(SAAppConfig.RemotePath, SAAppConfig.LanguagePlatform + "/" + SAAppConfig.LuaPathName); //lua 缓存 //unity资源 abs = new AssetBundle[(version.Count - 3) / 2 + 2]; //Platform Platform.manifest lua.bytes other.manifest abs_position = 0; //shader loadAssetBundleManifest(SAAppConfig.LanguagePlatform + "s"); //资源 loadAssetBundleManifest(SAAppConfig.LanguagePlatform); for (int i = 0; i < abs.Length; ++i) { if (null != abs[i]) { abs[i].Unload(false); abs[i] = null; } } SACache.getResDictionary(SAACollection.AtlasStr).Clear(); abs_position = 0; removeEventDispatcher(SAACollection.REFRESH + ActionCollection.LocalFile); //资源加载 dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile + SAACollection.COMPLETE); //更新完成 }
private void addDependToCache(string dependName, string dir) { int dot = dependName.LastIndexOf('.'); string contrast = dependName.Substring(0, dot); //缓存名称 string cacheName = dependName.Substring(0, dependName.IndexOf('.')); //缓存集合 Dictionary <string, System.Object> assetCache = SACache.getResDictionary(cacheName); if (null != assetCache && !assetCache.ContainsKey(contrast)) { AssetBundle ab = AssetBundle.LoadFromFile(Path.Combine(SAAppConfig.RemotePath, dir + "/" + dependName));//加载依赖文件 dependName = SAAppConfig.LocalDevDir.ToLower() + dependName.Substring(0, dot).Replace(".", "/") + dependName.Substring(dot); abs[abs_position++] = ab; dot = contrast.IndexOf(".") + 1; string tempContrast = contrast.Substring(dot); if (SAAppConfig.CacheModel || (cacheName.Equals(SAACollection.UIStr) && tempContrast.Length >= SAACollection.ComminLen && tempContrast.Substring(0, SAACollection.ComminLen).Equals(SAACollection.CommonStr))) { assetCache[contrast] = ab.LoadAsset(dependName); } else if (cacheName.Equals(SAACollection.ShaderStr)) { string[] names = ab.GetAllAssetNames(); string tempKey; string tempName; int tempKeyBegin; for (int i = 0; i < names.Length; ++i) { tempName = names[i]; tempKeyBegin = tempName.LastIndexOf("/") + 1; tempKey = tempName.Substring(tempKeyBegin, tempName.Length - tempKeyBegin - SAACollection.MatSuffixLen); assetCache[tempKey] = ab.LoadAsset(tempName); } } } }