AssetbundleConfig loadABConfig() { string fullpath = AssetBundleInfo.assetPath_local + "\\" + "abConfig.txt"; fullpath = fullpath.Replace("/", "\\"); if (File.Exists(fullpath)) { StreamReader sr = File.OpenText(fullpath); string text = sr.ReadToEnd(); sr.Close(); return(AssetbundleConfig.FromStr(text)); } else { fullpath = AssetBundleInfo.curPlatformFloder + "/abConfig"; Debug.Log("fullpath:" + fullpath); TextAsset ta = Resources.Load <TextAsset>(fullpath); if (ta == null) { Debug.LogError("not find abConfig at resource dir"); return(null); } return(AssetbundleConfig.FromStr(ta.text)); } }
public AssetBase() { gloabalSourceDic = new Dictionary <string, Object>(); sceneSourceDic = new Dictionary <string, Object>(); curAssetVersion = getAssetinfoFromLocal(); abConfig = loadABConfig(); gameAssetConfig = loadGameAssetConfig(); if (curAssetVersion == null) { Debug.LogError("curAssetVersion null"); } else { Debug.Log("本地资源版本号:" + curAssetVersion.assetVersion); // AppFacade.Ins.Log(BugType.log, "本地资源版本号"+ curAssetVersion.assetVersion); } loader = new AssetBundleLoader(); }
/// <summary> /// 拉资源配置信息 /// </summary> /// <param name="url"></param> /// <param name="back"></param> void pullAssetinfoFromSer(System.Action <AssetVersion> back) { string VersionPath = AssetBundleInfo.assetPath_server + "/" + "assetVersionInfo.txt"; //资源版本信息 string ConfigPath = AssetBundleInfo.assetPath_server + "/" + "abConfig.txt"; //资源包配置信息 string GameAssetConfigPath = AssetBundleInfo.assetPath_server + "/" + "gameAssetConfig.txt"; //游戏资源预加载信息 loader.LoadFileFromServer(GameAssetConfigPath, (string str0) => { gameAssetConfig = GameAssetConfig.FromStr(str0); loader.LoadFileFromServer(ConfigPath, (string str) => { Debug.Log("config file download"); abConfig = AssetbundleConfig.FromStr(str); loader.LoadFileFromServer(VersionPath, (string str1) => { AssetVersion av = AssetVersion.FromString(str1); if (back != null) { back(av); } }); }); }); }
public static AssetbundleConfig FromStr(string str) { AssetbundleConfig abc = new AssetbundleConfig(); string[] strs = str.Split('|'); if (strs.Length != 2) { return(null); } int.TryParse(strs[0], out abc.resourceVersion); string[] table = strs[1].Split(','); string[] kp; for (int i = 0; i < table.Length; i++) { kp = table[i].Split('&'); if (kp.Length == 2) { abc.AddAssetBundle(kp[0], kp[1]); } } return(abc); }