示例#1
0
        /// <summary>
        /// Builds an Android Player with the specified options.
        /// Note: the specified <see cref="BuildPlayerOptions.locationPathName"/> field is ignored and the
        /// Android Player is written to a temporary file whose path is returned as a string.
        /// </summary>
        /// <returns>The path to the file if the build succeeded, or null if it failed or was cancelled.</returns>
        public virtual string BuildAndroidPlayer(BuildPlayerOptions buildPlayerOptions)
        {
            var workingDirectory = new DirectoryInfo(_workingDirectoryPath);

            if (workingDirectory.Exists)
            {
                workingDirectory.Delete(true);
            }

            workingDirectory.Create();

            if (UseNativeAppBundleSupport)
            {
                AndroidAppBundle.EnableNativeBuild();
            }

            var androidPlayerFilePath = Path.Combine(workingDirectory.FullName, "tmp.aab");

            Debug.LogFormat("Building Android Player: {0}", androidPlayerFilePath);
            // This Android Player is an intermediate build artifact, so use a temporary path for the output file path.
            var updatedBuildPlayerOptions = new BuildPlayerOptions
            {
                assetBundleManifestPath = buildPlayerOptions.assetBundleManifestPath,
                locationPathName        = androidPlayerFilePath,
                options     = buildPlayerOptions.options,
                scenes      = buildPlayerOptions.scenes,
                target      = buildPlayerOptions.target,
                targetGroup = buildPlayerOptions.targetGroup
            };

            // Do not use BuildAndSign since this signature won't be used.
            return(_androidBuilder.Build(updatedBuildPlayerOptions) ? androidPlayerFilePath : null);
        }
示例#2
0
        /// <summary>
        /// Builds an Android Player with the specified options.
        /// Note: the specified <see cref="BuildPlayerOptions.locationPathName"/> field is ignored and the
        /// Android Player is written to a temporary file whose path is returned as a string.
        /// </summary>
        /// <returns>True if the build succeeded, or false if it failed or was cancelled.</returns>
        public virtual bool BuildAndroidPlayer(BuildPlayerOptions buildPlayerOptions)
        {
            var workingDirectory = new DirectoryInfo(_workingDirectoryPath);

            if (workingDirectory.Exists)
            {
                workingDirectory.Delete(true);
            }

            workingDirectory.Create();

            if (UseNativeAppBundleSupport)
            {
                AndroidAppBundle.EnableNativeBuild();
            }

            Debug.LogFormat("Building Android Player: {0}", AndroidPlayerFilePath);
            // This Android Player is an intermediate build artifact, so use a temporary path for the output file path.
            var updatedBuildPlayerOptions = new BuildPlayerOptions
            {
                assetBundleManifestPath = buildPlayerOptions.assetBundleManifestPath,
                locationPathName        = AndroidPlayerFilePath,
                options     = buildPlayerOptions.options,
                scenes      = buildPlayerOptions.scenes,
                target      = buildPlayerOptions.target,
                targetGroup = buildPlayerOptions.targetGroup
            };

            if (EditorUserBuildSettings.androidBuildSystem == AndroidBuildSystem.Gradle)
            {
                EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
            }

            // Do not use BuildAndSign since this signature won't be used.
            var buildSucceeded = _androidBuilder.Build(updatedBuildPlayerOptions);

            if (!buildSucceeded)
            {
                return(false);
            }

            if (!File.Exists(AndroidPlayerFilePath))
            {
                // If the build is canceled late, sometimes the build "succeeds" but the file is missing.
                // Since this may be intentional, don't display an onscreen error dialog. However, just
                // in case the build wasn't canceled, print a warning instead of silently failing.
                Debug.LogWarningFormat(
                    "The Android Player file \"{0}\"is missing, possibly because of a late build cancellation.",
                    AndroidPlayerFilePath);
                return(false);
            }

            return(true);
        }
示例#3
0
        /// <summary>
        /// Builds an Android Player with the specified options.
        /// Note: the specified <see cref="BuildPlayerOptions.locationPathName"/> field is ignored and the
        /// Android Player is written to a temporary file.
        /// </summary>
        public virtual AndroidBuildResult BuildAndroidPlayer(BuildPlayerOptions buildPlayerOptions)
        {
            var workingDirectory = new DirectoryInfo(_workingDirectoryPath);

            if (workingDirectory.Exists)
            {
                workingDirectory.Delete(true);
            }

            workingDirectory.Create();

            if (UseNativeAppBundleSupport)
            {
                AndroidAppBundle.EnableNativeBuild();
            }

            Debug.LogFormat("Building Android Player: {0}", AndroidPlayerFilePath);
            // This Android Player is an intermediate build artifact, so use a temporary path for the output file path.
            var updatedBuildPlayerOptions = new BuildPlayerOptions
            {
                assetBundleManifestPath = buildPlayerOptions.assetBundleManifestPath,
                locationPathName        = AndroidPlayerFilePath,
                options     = buildPlayerOptions.options,
                scenes      = buildPlayerOptions.scenes,
                target      = buildPlayerOptions.target,
                targetGroup = buildPlayerOptions.targetGroup
            };

            if (EditorUserBuildSettings.androidBuildSystem == AndroidBuildSystem.Gradle)
            {
                EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
            }

            // Do not use BuildAndSign since this signature won't be used.
            return(_androidBuilder.Build(updatedBuildPlayerOptions));
        }