/// <summary> /// Package the specified AssetBundle files, which vary only by <see cref="TextureCompressionFormat"/>, in an /// <see cref="AssetPack"/> with the specified delivery mode. /// </summary> /// <param name="compressionFormatToAssetBundleFilePath"> /// A dictionary from <see cref="TextureCompressionFormat"/> to AssetBundle files.</param> /// <param name="deliveryMode">The <see cref="AssetPackDeliveryMode"/> for the asset pack.</param> /// <exception cref="ArgumentException">If the dictionary or asset pack name is invalid.</exception> /// <exception cref="FileNotFoundException">If any AssetBundle file doesn't exist.</exception> public void AddAssetBundles( IDictionary <TextureCompressionFormat, string> compressionFormatToAssetBundleFilePath, AssetPackDeliveryMode deliveryMode) { if (compressionFormatToAssetBundleFilePath.Count == 0) { throw new ArgumentException("Dictionary should contain at least one AssetBundle"); } if (compressionFormatToAssetBundleFilePath.All(kvp => kvp.Key != TextureCompressionFormat.Default)) { throw new ArgumentException("Dictionary should contain at least one Default compression AssetBundle"); } var assetPackName = GetAssetPackName(compressionFormatToAssetBundleFilePath.Values.First()); if (compressionFormatToAssetBundleFilePath.Any(kvp => assetPackName != GetAssetPackName(kvp.Value))) { throw new ArgumentException("All AssetBundles in the Dictionary must have the same name"); } AssetPacks[assetPackName] = new AssetPack { DeliveryMode = deliveryMode, CompressionFormatToAssetBundleFilePath = new Dictionary <TextureCompressionFormat, string>(compressionFormatToAssetBundleFilePath) }; }
/// <summary> /// Package the specified AssetBundle file in its own <see cref="AssetPack"/> with the specified delivery mode. /// The name of the created asset pack will match that of the specified AssetBundle file. /// </summary> /// <param name="assetBundleFilePath">The path to a single AssetBundle file.</param> /// <param name="deliveryMode">The <see cref="AssetPackDeliveryMode"/> for the asset pack.</param> /// <exception cref="ArgumentException">If the asset pack name is invalid.</exception> /// <exception cref="FileNotFoundException">If the AssetBundle file doesn't exist.</exception> public void AddAssetBundle(string assetBundleFilePath, AssetPackDeliveryMode deliveryMode) { var assetPackName = GetAssetPackName(assetBundleFilePath); AssetPacks[assetPackName] = new AssetPack { DeliveryMode = deliveryMode, AssetBundleFilePath = assetBundleFilePath }; }
/// <summary> /// Package all raw assets in the specified folder in an <see cref="AssetPack"/> with the specified name and /// using the specified delivery mode. /// </summary> /// <param name="assetPackName">The name of the asset pack.</param> /// <param name="assetsFolderPath"> /// The path to a directory whose files will be directly copied into the asset pack during app bundle creation. /// </param> /// <param name="deliveryMode">The <see cref="AssetPackDeliveryMode"/> for the asset pack.</param> /// <exception cref="ArgumentException">If the <see cref="assetPackName"/> is invalid.</exception> /// <exception cref="FileNotFoundException">If the <see cref="assetsFolderPath"/> doesn't exist.</exception> public void AddAssetsFolder(string assetPackName, string assetsFolderPath, AssetPackDeliveryMode deliveryMode) { var directoryInfo = new DirectoryInfo(assetsFolderPath); if (!directoryInfo.Exists) { throw new FileNotFoundException("Asset pack directory doesn't exist", assetsFolderPath); } CheckAssetPackName(assetPackName); AssetPacks[assetPackName] = new AssetPack { DeliveryMode = deliveryMode, AssetPackDirectoryPath = assetsFolderPath }; }
/// <summary> /// Package the specified raw assets in the specified folders, keyed by <see cref="TextureCompressionFormat"/>, /// in an <see cref="AssetPack"/> with the specified delivery mode. /// When using Play Asset Delivery APIs, only the folder for the device's preferred texture compression format /// will be delivered. /// </summary> /// <param name="assetPackName">The name of the asset pack.</param> /// <param name="compressionFormatToAssetPackDirectoryPath"> /// A dictionary from <see cref="TextureCompressionFormat"/> to the path of directories of files that will be /// directly copied into the asset pack during app bundle creation.</param> /// <param name="deliveryMode">The <see cref="AssetPackDeliveryMode"/> for the asset pack.</param> /// <exception cref="ArgumentException">If the dictionary or asset pack name is invalid.</exception> public void AddAssetsFolders( string assetPackName, IDictionary <TextureCompressionFormat, string> compressionFormatToAssetPackDirectoryPath, AssetPackDeliveryMode deliveryMode) { if (compressionFormatToAssetPackDirectoryPath.Count == 0) { throw new ArgumentException("Dictionary should contain at least one path"); } if (compressionFormatToAssetPackDirectoryPath.All(kvp => kvp.Key != TextureCompressionFormat.Default)) { throw new ArgumentException("Dictionary should contain at least one Default compression path"); } CheckAssetPackName(assetPackName); AssetPacks[assetPackName] = new AssetPack { DeliveryMode = deliveryMode, CompressionFormatToAssetPackDirectoryPath = new Dictionary <TextureCompressionFormat, string>(compressionFormatToAssetPackDirectoryPath) }; }