// REVIEW: need review. switch to notify changed schema public void PropagateVersionToUsages(IProjectReference projectReference) { bool usageUpdated = false; if (HasProjectAsParent(projectReference, false)) { if (_project.Parent.Version != projectReference.Version) { _project.Parent.Version = projectReference.Version; usageUpdated = true; } } foreach (var dependency in AllDependencies.Where(d => d.ReferenceOperations().ReferenceEqualTo(projectReference, false))) { if (dependency.Version.IsDefined && dependency.Version != projectReference.Version) { dependency.Version = projectReference.Version; usageUpdated = true; } } foreach (var plugin in AllPlugins.Where(d => d.ReferenceOperations().ReferenceEqualTo(projectReference, false))) { if (plugin.Version.IsDefined && plugin.Version != projectReference.Version) { plugin.Version = projectReference.Version; usageUpdated = true; } } // TODO: Changed = usageUpdated; }
public static void BuildDLCConfig(DLCItem dlc) { //清除缓存 PackedAssets_Internal.Clear(); PackedAssets_Native.Clear(); PackedAssets_DLC.Clear(); Builds.Clear(); Rules.Clear(); AllDependencies.Clear(); AllAssets.Clear(); AllBundles.Clear(); AllSharedBundles.Clear(); Consts.Clear(); //永远提前打包Internal if (!dlc.IsInternal) { BuildDLCConfigInternal(Internal); } //如果不是NativeDLC则先BuildNativeDLC,防止资源被其他DLC重复打包 if (!dlc.IsInternal && !dlc.IsNative) { BuildDLCConfigInternal(Native); } BuildDLCConfigInternal(dlc); }
private static void CollectDependencies(string path) { var files = GetFilesWithoutDirectories(path); for (int i = 0; i < files.Count; i++) { var item = files[i]; var dependencies = AssetDatabase.GetDependencies(item); if (EditorUtility.DisplayCancelableProgressBar(string.Format("Collecting... [{0}/{1}]", i, files.Count), item, i * 1f / files.Count)) { break; } foreach (var assetPath in dependencies) { if (!AllDependencies.ContainsKey(assetPath)) { AllDependencies[assetPath] = new HashSet <string>(); } if (!AllDependencies[assetPath].Contains(item)) { AllDependencies[assetPath].Add(item); } } } }
/// <summary> /// 活的构建的数据 /// </summary> /// <param name="manifestPath"></param> /// <returns></returns> private static List <AssetBundleBuild> GenerateAssetBundleBuildData(DLCItem dlc) { if (dlc.IsInternal) { PackedAssets_Internal.Clear(); } else if (dlc.IsNative) { PackedAssets_Native.Clear(); } PackedAssets_DLC.Clear(); Builds.Clear(); Rules.Clear(); AllDependencies.Clear(); AllAssets.Clear(); AllBundles.Clear(); AllSharedBundles.Clear(); //建立其他文件 List <BuildRuleConfig> tempBuildDatas = dlc.BuildRuleData; if (tempBuildDatas == null && tempBuildDatas.Count == 0) { CLog.Error("没有配置相关的AssetBundle信息"); return(null); } foreach (var item in tempBuildDatas) { BuildRule buildRule = null; if (item.BuildRuleType == BuildRuleType.Directroy) { buildRule = new BuildAssetsWithDirectroy(dlc, item); } else if (item.BuildRuleType == BuildRuleType.FullPath) { buildRule = new BuildAssetsWithPath(dlc, item); } else if (item.BuildRuleType == BuildRuleType.File) { buildRule = new BuildAssetsWithFile(dlc, item); } Rules.Add(buildRule); } //搜集依赖的资源 foreach (var item in Rules) { CollectDependencies(item.Config.FullSearchPath); } //打包共享的资源 BuildSharedAssets(dlc); foreach (var item in Rules) { item.Build(); } EditorUtility.ClearProgressBar(); return(Builds); }
private bool HasDependencyOn(IProjectReference projectReference, bool strictVersion) { return(AllDependencies.Any(d => d.ReferenceOperations().ReferenceEqualTo(projectReference, strictVersion))); }
public LinkedCode GetLinkedCode() { var allDeps = AllDependencies.Where(x => x.HasCode).ToList(); var changedDeps = allDeps.Where(x => x.CodeChanged || x == this).ToList(); var notChangedDeps = allDeps.Where(x => !x.CodeChanged && x != this).ToList(); var changedDepsChanged = true; while (changedDepsChanged) { changedDepsChanged = false; foreach (var nc in notChangedDeps) { var ncDeps = nc.AllDependencies; var depChanged = ncDeps.Any(changedDeps.Contains); if (depChanged) { changedDeps.Add(nc); notChangedDeps.Remove(nc); changedDepsChanged = true; break; } } } var codes = changedDeps; var usings = codes.SelectMany(x => x.Usings).Distinct().ToList(); var suffix = DateTime.UtcNow.Ticks.ToString(); var renames = codes. Select(x => Tuple.Create( new System.Text.RegularExpressions.Regex("\\b" + x.Name + "\\b"), x.Name + suffix)). ToList(); Func <string, string> rename = c => { var rc = c; foreach (var r in renames) { rc = r.Item1.Replace(rc, r.Item2); } return(rc); }; return(new LinkedCode( valueExpression: "new " + (HasNamespace ? FullNamespace + "." : "") + Name + suffix + "()", declarations: string.Join(Environment.NewLine, codes.Select(x => { var us = string.Join(Environment.NewLine, usings); var renamedCode = rename(x.Code); if (x.HasNamespace) { return "namespace " + x.FullNamespace + "{" + us + "\n" + renamedCode + "}"; } else { return us + "\n" + renamedCode; } })), types: codes.ToArray(), mainType: this)); }