private void CookBundle(string bundleName, List <FileInfo> assets, List <string> bundleBackups) { OutputBundle = CreateOutputBundle(bundleName, bundleBackups); try { CookBundleHelper(); // Open the bundle again in order to make some plugin post-processing (e.g. generate code from scene assets) using (new DirectoryChanger(The.Workspace.AssetsDirectory)) { PluginLoader.AfterAssetsCooked(bundleName); } } finally { OutputBundle.Dispose(); OutputBundle = null; } void CookBundleHelper() { Console.WriteLine("------------- Cooking Assets ({0}) -------------", bundleName); var savedInputBundle = InputBundle; AssetBundle.SetCurrent(new CustomSetAssetBundle(InputBundle, assets), resetTexturePool: false); // Every asset bundle must have its own atlases folder, so they aren't conflict with each other atlasesPostfix = bundleName != CookingRulesBuilder.MainBundleName ? bundleName : ""; try { foreach (var stage in CookStages) { CheckCookCancelation(); stage.Action(); } // Warn about non-power of two textures foreach (var path in OutputBundle.EnumerateFiles()) { if ((OutputBundle.GetAttributes(path) & AssetAttributes.NonPowerOf2Texture) != 0) { Console.WriteLine("Warning: non-power of two texture: {0}", path); } } } finally { AssetBundle.SetCurrent(savedInputBundle, resetTexturePool: false); ModelsToRebuild.Clear(); atlasesPostfix = ""; } } }
private int CalculateOperationCount(List <string> bundles) { var assetCount = 0; var assetsGroupedByBundles = GetAssetsGroupedByBundles(InputBundle.EnumerateFileInfos(), bundles); for (int i = 0; i < bundles.Count; i++) { var savedInputBundle = InputBundle; AssetBundle.SetCurrent( new CustomSetAssetBundle(InputBundle, assetsGroupedByBundles[i]), resetTexturePool: false); OutputBundle = CreateOutputBundle(bundles[i], bundleBackups: null); try { assetCount += CookStages.Sum(stage => stage.GetOperationCount()); } finally { OutputBundle.Dispose(); OutputBundle = null; AssetBundle.SetCurrent(savedInputBundle, resetTexturePool: false); } } return(assetCount); }