Пример #1
0
 /// <summary>
 /// Builds an Android App Bundle using the specified build options.
 ///
 /// Before calling this method use PlayInstantBuildSettings.SetInstantBuildType() to decide whether to build an
 /// instant app bundle or a regular app bundle for installed apps.
 ///
 /// If this method is invoked in Batch Mode, for example from a command line build, then the entire build will
 /// run on the main thread. In this case the <see cref="forceSynchronousBuild"/> parameter has no effect.
 ///
 /// If this method is invoked by a script running from an interactive Editor UI, some of the build will run on
 /// a background thread and this method will return before the full build is complete. This behavior can be
 /// overridden by setting the <see cref="forceSynchronousBuild"/> parameter to true; in this case the entire
 /// build will run on the main thread. Note that this freezes the Editor UI.
 ///
 /// The asynchronous BuildBundle() method method should be preferred when building on Unity 2018.4 or higher.
 /// </summary>
 /// <param name="buildPlayerOptions">A Unity BuildPlayerOptions including the output file path.</param>
 /// <param name="assetPackConfig">The asset packs to include in the Android App Bundle, if any.</param>
 /// <param name="forceSynchronousBuild">If true, the build should only run on the main thread.</param>
 /// <returns>
 /// True if the build succeeded or began running in the background, false if it failed or was cancelled.
 /// </returns>
 public static bool BuildBundle(
     BuildPlayerOptions buildPlayerOptions,
     AssetPackConfig assetPackConfig = null,
     bool forceSynchronousBuild      = false)
 {
     return(AppBundlePublisher.Build(buildPlayerOptions, assetPackConfig, forceSynchronousBuild));
 }
Пример #2
0
        /// <summary>
        /// Run one or more AssetBundle builds with the specified texture compression formats.
        /// Notes about the <see cref="outputPath"/> parameter:
        /// - If a relative path is provided, the file paths in the returned AssetPackConfig will be relative paths.
        /// - If an absolute path is provided, the file paths in the returned object will be absolute paths.
        /// - AssetBundle builds for additional texture formats will be created in siblings of this directory. For
        ///   example, for outputDirectory "a/b/c" and texture format ASTC, there will be a directory "a/b/c#tcf_astc".
        /// - This directory and any sibling directories must be empty or not exist, otherwise an exception is thrown.
        /// </summary>
        /// <param name="outputPath">The output directory for the ETC1 AssetBundles. See other notes above.</param>
        /// <param name="builds">The main argument to <see cref="BuildPipeline"/>.</param>
        /// <param name="deliveryMode">A delivery mode to apply to every asset pack in the generated config.</param>
        /// <param name="additionalTextureFormats">Texture formats to build for in addition to ETC1.</param>
        /// <param name="assetBundleOptions">Options to pass to <see cref="BuildPipeline"/>.</param>
        /// <returns>An <see cref="AssetPackConfig"/> containing file paths to all generated AssetBundles.</returns>
        public static AssetPackConfig BuildAssetBundles(
            string outputPath,
            AssetBundleBuild[] builds,
            AssetPackDeliveryMode deliveryMode,
            IEnumerable <MobileTextureSubtarget> additionalTextureFormats = null,
            BuildAssetBundleOptions assetBundleOptions = BuildAssetBundleOptions.UncompressedAssetBundle)
        {
            var nameToTextureFormatToPath = BuildAssetBundles(
                outputPath, builds, assetBundleOptions, MobileTextureSubtarget.ETC, additionalTextureFormats);
            var assetPackConfig = new AssetPackConfig();

            foreach (var compressionToPath in nameToTextureFormatToPath.Values)
            {
                assetPackConfig.AddAssetBundles(compressionToPath, deliveryMode);
            }

            return(assetPackConfig);
        }
Пример #3
0
 /// <summary>
 /// Builds an Android App Bundle using the specified build options. Before calling this method use
 /// PlayInstantBuildSettings.SetInstantBuildType() to decide whether to build an instant app bundle or a
 /// regular app bundle for installed apps.
 /// </summary>
 /// <param name="buildPlayerOptions">A Unity BuildPlayerOptions including the output file path.</param>
 /// <param name="assetPackConfig">The asset packs to include in the Android App Bundle, if any.</param>
 /// <returns>True if the build succeeded, false if it failed or was cancelled.</returns>
 public static bool BuildBundle(BuildPlayerOptions buildPlayerOptions, AssetPackConfig assetPackConfig = null)
 {
     return(AppBundlePublisher.Build(buildPlayerOptions, assetPackConfig ?? new AssetPackConfig()));
 }