/// <summary> /// 同步配置至ResourcesManifestData /// </summary> public void SyncConfigTo(ResourcesManifestData res) { if (res == null) { return; } res.strVersion = Data.strVersion; res.IsAllCompress = Data.IsAllCompress; res.IsAllNative = Data.IsAllNative; string path = Data.BuildStartLocalPath.ToLower(); SyncAssetConfig(path, Data.Assets.Root, res, true); if (Data.Scenes.Scenes.Count > 0) { foreach (var element in Data.Scenes.Scenes) { SyncSceneAssetConfig(element, res, true); } } }
/// <summary> /// /// </summary> public ResourcesManifest() { Data = new ResourcesManifestData(); }
/// <summary> /// 同步场景资源配置 /// </summary> static void SyncSceneAssetConfig(AssetBundleBuildData.SceneBuild.Element element, ResourcesManifestData data , bool is_write) { string path = element.ScenePath.ToLower(); string key = EditorCommon.ConvertToAssetBundleName(path); ResourcesManifestData.AssetBundle ab_data; if (data.AssetBundles.TryGetValue(key, out ab_data)) { if (is_write) { ab_data.IsCompress = element.IsCompress; ab_data.IsNative = element.IsNative; ab_data.IsPermanent = false; ab_data.IsStartupLoad = false; } else { element.IsCompress = ab_data.IsCompress; element.IsNative = ab_data.IsNative; } } }
/// <summary> /// 同步资源配置 /// </summary> static void SyncAssetConfig(string path, AssetBundleBuildData.AssetBuild.Element element, ResourcesManifestData data , bool is_write) { if (element.Rule == (int)emAssetBundleNameRule.Ignore) { return; } string key = EditorCommon.ConvertToAssetBundleName(path); ResourcesManifestData.AssetBundle ab_data; if (data.AssetBundles.TryGetValue(key, out ab_data)) { if (is_write) { ab_data.IsCompress = element.IsCompress; ab_data.IsNative = element.IsNative; ab_data.IsPermanent = element.IsPermanent; ab_data.IsStartupLoad = element.IsStartupLoad; } else { element.IsCompress = ab_data.IsCompress; element.IsNative = ab_data.IsNative; element.IsPermanent = ab_data.IsPermanent; element.IsStartupLoad = ab_data.IsStartupLoad; } } if (element.Children != null && element.Children.Count > 0) { foreach (var child in element.Children) { string child_path = path + "/" + child.Name.ToLower(); SyncAssetConfig(child_path, child, data, is_write); } } }
/// <summary> /// 同步场景资源配置 /// </summary> static void SyncSceneAssetConfig(AssetBundleBuildData.SceneBuild.Element element, ResourcesManifestData data , bool is_write) { string localPath = EditorCommon.AbsoluteToRelativePath(element.ScenePath); localPath = localPath.ToLower(); // 场景文件与配置文件 string[] files = new string[] { localPath, SceneConfig.GetSceneConfigPath(localPath).ToLower() }; foreach (var path in files) { string key = EditorCommon.ConvertToAssetBundleName(path); ResourcesManifestData.AssetBundle ab_data; if (data.AssetBundles.TryGetValue(key, out ab_data)) { if (is_write) { ab_data.IsCompress = element.IsCompress; ab_data.IsNative = element.IsNative; ab_data.IsPermanent = false; ab_data.IsStartupLoad = false; } else { element.IsCompress = ab_data.IsCompress; element.IsNative = ab_data.IsNative; } } } }
/// <summary> /// 重新载入数据 /// </summary> public void SyncConfigForm(ResourcesManifestData res) { asset_bundle_build_.SyncConfigFrom(res); }