//生成游戏中使用的配置文件 public void CreatBundelPackageConfig() { Dictionary <string, object> data = new Dictionary <string, object>(); Dictionary <string, object> gameRelyBundles = new Dictionary <string, object>(); for (int i = 0; i < relyPackages.Count; i++) { //生成游戏中使用的依赖包数据 Dictionary <string, object> pack = new Dictionary <string, object>(); pack.Add("name", relyPackages[i].name); pack.Add("path", relyPackages[i].path); pack.Add("relyPackages", new string[0]); pack.Add("md5", MD5Tool.GetFileMD5(GetExportPath(relyPackages[i].path, relyPackages[i].name))); //获取bundle包的md5 gameRelyBundles.Add(relyPackages[i].name, pack); } Dictionary <string, object> gameAssetsBundles = new Dictionary <string, object>(); for (int i = 0; i < bundles.Count; i++) { //生成游戏中使用的bundle包数据 Dictionary <string, object> pack = new Dictionary <string, object>(); pack.Add("name", bundles[i].name); pack.Add("path", bundles[i].path); pack.Add("relyPackages", GetRelyPackNames(bundles[i].relyPackagesMask)); //获取依赖包的名字 pack.Add("md5", MD5Tool.GetFileMD5(GetExportPath(bundles[i].path, bundles[i].name))); //获取bundle包的md5 //pack.loadType = ResLoadType.Streaming; //默认放在沙盒路径下 gameAssetsBundles.Add(bundles[i].name, pack); } data.Add(ResourcesConfigManager.c_relyBundleKey, gameRelyBundles); data.Add(ResourcesConfigManager.c_bundlesKey, gameAssetsBundles); //保存游戏中读取的配置文件 //ConfigManager.SaveData(ResourcesConfigManager.c_configFileName, gameConfig); float time = Time.realtimeSinceStartup; EditorUtil.WriteStringByFile( PathTool.GetAbsolutePath(ResLoadLocation.Resource, ResourcesConfigManager.c_ManifestFileName + "." + ConfigManager.c_expandName) , FrameWork.Json.Serialize(data)); Debug.Log("保存完毕 序列化时间: " + (Time.realtimeSinceStartup - time)); AssetDatabase.Refresh(); }
//生成游戏中使用的配置文件 public void CreatBundelPackageConfig() { Dictionary <string, SingleField> gameConfig = new Dictionary <string, SingleField>(); Dictionary <string, ResourcesConfig> gameRelyBundles = new Dictionary <string, ResourcesConfig>(); for (int i = 0; i < relyPackages.Count; i++) { //生成游戏中使用的依赖包数据 ResourcesConfig pack = new ResourcesConfig(); pack.name = relyPackages[i].name; pack.path = relyPackages[i].path; pack.relyPackages = new string[0]; pack.md5 = MD5Tool.GetFileMD5(GetExportPath(pack.path, pack.name)); //获取bundle包的md5 //pack.loadType = ResLoadType.Streaming; //默认放在沙盒路径下 gameRelyBundles.Add(pack.name, pack); } Dictionary <string, ResourcesConfig> gameAssetsBundles = new Dictionary <string, ResourcesConfig>(); for (int i = 0; i < bundles.Count; i++) { //生成游戏中使用的bundle包数据 ResourcesConfig pack = new ResourcesConfig(); pack.name = bundles[i].name; pack.path = bundles[i].path; pack.relyPackages = GetRelyPackNames(bundles[i].relyPackagesMask); //获取依赖包的名字 pack.md5 = MD5Tool.GetFileMD5(GetExportPath(pack.path, pack.name)); //获取bundle包的md5 //pack.loadType = ResLoadType.Streaming; //默认放在沙盒路径下 gameAssetsBundles.Add(pack.name, pack); } gameConfig.Add(ResourcesConfigManager.c_relyBundleKey, new SingleField(JsonTool.Dictionary2Json <ResourcesConfig>(gameRelyBundles))); gameConfig.Add(ResourcesConfigManager.c_bundlesKey, new SingleField(JsonTool.Dictionary2Json <ResourcesConfig>(gameAssetsBundles))); //保存游戏中读取的配置文件 ConfigManager.SaveData(ResourcesConfigManager.c_configFileName, gameConfig); AssetDatabase.Refresh(); }