Exemplo n.º 1
0
        private static bool Build(AppBundleBuilder appBundleBuilder, BuildPlayerOptions buildPlayerOptions,
                                  AssetPackConfig assetPackConfig, AppBundleBuildSettings buildSettings)
        {
            if (buildSettings.requirePrerequisiteChecks && !appBundleBuilder.Initialize(new BuildToolLogger()))
            {
                return(false);
            }

            buildSettings.aabFilePath = buildPlayerOptions.locationPathName;
            Debug.LogFormat("Building app bundle: {0}", buildSettings.aabFilePath);
            bool buildSucceeded = appBundleBuilder.BuildAndroidPlayer(buildPlayerOptions);

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

            if (IsBatchMode)
            {
                return(appBundleBuilder.CreateBundle(buildSettings.aabFilePath, assetPackConfig));
            }

#if UNITY_2018_3_OR_NEWER
            CreateBundleAsync(appBundleBuilder, buildSettings, assetPackConfig);
#else
            var task = new AppBundlePostBuildTask
            {
                buildSettings = buildSettings,
                serializableAssetPackConfig = SerializationHelper.Serialize(assetPackConfig),
                workingDirectoryPath        = appBundleBuilder.WorkingDirectoryPath
            };
            PostBuildRunner.RunTask(task);
#endif
            return(true);
        }
        private static bool Build(AppBundleBuilder appBundleBuilder, AppBundleBuildSettings buildSettings)
        {
            var androidBuildResult = appBundleBuilder.BuildAndroidPlayer(buildSettings.buildPlayerOptions);

            if (!androidBuildResult.Succeeded)
            {
                return(false);
            }

            var aabFilePath = buildSettings.buildPlayerOptions.locationPathName;

            if (IsBatchMode || buildSettings.forceSynchronousBuild)
            {
                var errorMessage = appBundleBuilder.CreateBundle(aabFilePath, buildSettings.assetPackConfig);
                return(errorMessage == null);
            }

#if UNITY_2018_3_OR_NEWER
            CreateBundleAsync(appBundleBuilder, aabFilePath, buildSettings.assetPackConfig, buildSettings.runOnDevice);
#else
            var task = new AppBundlePostBuildTask
            {
                serializableAssetPackConfig = SerializationHelper.Serialize(buildSettings.assetPackConfig),
                workingDirectoryPath        = appBundleBuilder.WorkingDirectoryPath,
                aabFilePath = aabFilePath,
                runOnDevice = buildSettings.runOnDevice
            };
            PostBuildRunner.RunTask(task);
#endif
            // This return value should be ignored since the build is being finished asynchronously.
            return(true);
        }
Exemplo n.º 3
0
        private static bool Build(AppBundleBuilder appBundleBuilder, BuildPlayerOptions buildPlayerOptions,
                                  AssetPackConfig assetPackConfig, AppBundleBuildSettings buildSettings)
        {
            if (buildSettings.requirePrerequisiteChecks && !appBundleBuilder.Initialize(new BuildToolLogger()))
            {
                return(false);
            }

            buildSettings.aabFilePath = buildPlayerOptions.locationPathName;
            Debug.LogFormat("Building app bundle: {0}", buildSettings.aabFilePath);
            buildSettings.androidPlayerFilePath = appBundleBuilder.BuildAndroidPlayer(buildPlayerOptions);
            if (buildSettings.androidPlayerFilePath == null)
            {
                return(false);
            }

            if (!File.Exists(buildSettings.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.",
                    buildSettings.androidPlayerFilePath);
                return(false);
            }

            if (IsBatchMode)
            {
                return(appBundleBuilder.CreateBundle(
                           buildSettings.aabFilePath, buildSettings.androidPlayerFilePath, assetPackConfig));
            }

#if UNITY_2018_3_OR_NEWER
            CreateBundleAsync(appBundleBuilder, buildSettings, assetPackConfig);
#else
            var task = new AppBundlePostBuildTask
            {
                buildSettings = buildSettings,
                serializableAssetPackConfig = SerializationHelper.Serialize(assetPackConfig),
                workingDirectoryPath        = appBundleBuilder.WorkingDirectoryPath
            };
            PostBuildRunner.RunTask(task);
#endif
            return(true);
        }