private static void CheckAssetPackName(string assetPackName) { if (!AndroidAppBundle.IsValidModuleName(assetPackName)) { throw new ArgumentException("Invalid asset pack name: " + assetPackName); } }
/// <summary> /// Run one or more AssetBundle builds with the specified texture compression formats. /// This variant allows for overriding the base format and provides a different return type. /// </summary> /// <param name="outputPath">The output directory for base AssetBundles. See the other method for notes.</param> /// <param name="builds">The main argument to <see cref="BuildPipeline"/>.</param> /// <param name="assetBundleOptions">Options to pass to <see cref="BuildPipeline"/>.</param> /// <param name="baseTextureFormat">The default format. Note: ETC1 is supported by all devices.</param> /// <param name="additionalTextureFormats">Texture formats to generate for in addition to the base.</param> /// <param name="allowClearDirectory">Allows this method to clear the contents of the output directory.</param> /// <returns>A dictionary from AssetBundle name to TextureCompressionFormat to file outputPath.</returns> public static Dictionary <string, Dictionary <TextureCompressionFormat, string> > BuildAssetBundles( string outputPath, AssetBundleBuild[] builds, BuildAssetBundleOptions assetBundleOptions, MobileTextureSubtarget baseTextureFormat, IEnumerable <MobileTextureSubtarget> additionalTextureFormats, bool allowClearDirectory) { if (builds == null || builds.Length == 0) { throw new ArgumentException("AssetBundleBuild parameter cannot be null or empty"); } foreach (var build in builds) { if (!AndroidAppBundle.IsValidModuleName(build.assetBundleName)) { throw new ArgumentException("Invalid AssetBundle name: " + build.assetBundleName); } } if (string.IsNullOrEmpty(outputPath)) { throw new ArgumentNullException("outputPath"); } CheckDirectory(outputPath, allowClearDirectory); // Make unique and silently remove the base format, if it was present. var textureSubtargets = new HashSet <MobileTextureSubtarget>( additionalTextureFormats ?? Enumerable.Empty <MobileTextureSubtarget>()); textureSubtargets.Remove(baseTextureFormat); // Note: GetCompressionFormatSuffix() will throw for unsupported formats. var paths = textureSubtargets.Select(format => outputPath + GetCompressionFormatSuffix(format)); foreach (var path in paths) { CheckDirectory(path, allowClearDirectory); } // Throws if the base format is invalid. GetCompressionFormat(baseTextureFormat); return(BuildAssetBundlesInternal( outputPath, builds, assetBundleOptions, baseTextureFormat, textureSubtargets)); }