public void Action() { var textures = new Dictionary <string, DateTime>(StringComparer.OrdinalIgnoreCase); foreach (var fileInfo in AssetCooker.InputBundle.EnumerateFileInfos(null, textureExtension)) { textures[fileInfo.Path] = fileInfo.LastWriteTime; } var atlasChainsToRebuild = new HashSet <string>(); // Figure out atlas chains to rebuild foreach (var atlasPartPath in AssetCooker.OutputBundle.EnumerateFiles().ToList()) { if (!atlasPartPath.EndsWith(atlasPartExtension, StringComparison.OrdinalIgnoreCase)) { continue; } // If atlas part has been outdated we should rebuild full atlas chain var srcTexturePath = Path.ChangeExtension(atlasPartPath, textureExtension); var bundleSHA1 = AssetCooker.OutputBundle.GetCookingRulesSHA1(atlasPartPath); if (bundleSHA1 == null) { throw new InvalidOperationException("CookingRules SHA1 for atlas part shouldn't be null"); } if ( !textures.ContainsKey(srcTexturePath) || AssetCooker.OutputBundle.GetFileLastWriteTime(atlasPartPath) != textures[srcTexturePath] || (!AssetCooker.CookingRulesMap[srcTexturePath].SHA1.SequenceEqual(bundleSHA1)) ) { srcTexturePath = AssetPath.Combine(The.Workspace.AssetsDirectory, srcTexturePath); var part = InternalPersistence.Instance.ReadObjectFromBundle <TextureAtlasElement.Params>(AssetCooker.OutputBundle, atlasPartPath); var atlasChain = Path.GetFileNameWithoutExtension(part.AtlasPath); atlasChainsToRebuild.Add(atlasChain); if (!textures.ContainsKey(srcTexturePath)) { AssetCooker.DeleteFileFromBundle(atlasPartPath); } else { srcTexturePath = Path.ChangeExtension(atlasPartPath, textureExtension); if (AssetCooker.CookingRulesMap[srcTexturePath].TextureAtlas != null) { var rules = AssetCooker.CookingRulesMap[srcTexturePath]; atlasChainsToRebuild.Add(rules.TextureAtlas); } else { AssetCooker.DeleteFileFromBundle(atlasPartPath); } } } } // Find which new textures must be added to the atlas chain foreach (var t in textures) { var atlasPartPath = Path.ChangeExtension(t.Key, atlasPartExtension); var cookingRules = AssetCooker.CookingRulesMap[t.Key]; var atlasNeedRebuld = cookingRules.TextureAtlas != null && !AssetCooker.OutputBundle.FileExists(atlasPartPath); if (atlasNeedRebuld) { atlasChainsToRebuild.Add(cookingRules.TextureAtlas); } else { UserInterface.Instance.IncreaseProgressBar(); } } foreach (var atlasChain in atlasChainsToRebuild) { AssetCooker.CheckCookCancelation(); BuildAtlasChain(atlasChain); } }