Exemple #1
0
        /// <summary>
        /// Do a build configured for UWP Applications to the specified path, returns the error from <see cref="BuildPlayer(UwpBuildInfo)"/>
        /// </summary>
        /// <param name="buildDirectory"></param>
        /// <param name="showDialog"></param>
        /// <param name="buildAppx"></param>
        /// <returns>True, if build was successful.</returns>
        public static async Task <bool> BuildPlayer(string buildDirectory, bool showDialog = true, bool buildAppx = false)
        {
            if (UnityPlayerBuildTools.CheckBuildScenes() == false)
            {
                return(false);
            }

            var buildInfo = new UwpBuildInfo
            {
                OutputDirectory = buildDirectory,
                Scenes          = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(scene => scene.path),
                BuildAppx       = buildAppx,
                AppIconPath     = UwpBuildDeployPreferences._3DAppIconPath,

                // Configure a post build action that will compile the generated solution
                PostBuildAction = PostBuildAction
            };

            async void PostBuildAction(IBuildInfo innerBuildInfo, BuildReport buildReport)
            {
                if (buildReport.summary.result != BuildResult.Succeeded)
                {
                    EditorUtility.DisplayDialog($"{PlayerSettings.productName} WindowsStoreApp Build {buildReport.summary.result}!", "See console for details", "OK");
                }
                else
                {
                    if (showDialog &&
                        !EditorUtility.DisplayDialog(PlayerSettings.productName, "Build Complete", "OK", "Build AppX"))
                    {
                        var _buildInfo = innerBuildInfo as UwpBuildInfo;
                        Debug.Assert(_buildInfo != null);
                        EditorAssemblyReloadManager.LockReloadAssemblies = true;
                        await UwpAppxBuildTools.BuildAppxAsync(_buildInfo);

                        EditorAssemblyReloadManager.LockReloadAssemblies = false;
                    }
                }
            }

            return(await BuildPlayer(buildInfo));
        }
Exemple #2
0
        /// <summary>
        /// Build the Uwp Player.
        /// </summary>
        /// <param name="buildInfo"></param>
        public static async Task <bool> BuildPlayer(UwpBuildInfo buildInfo)
        {
            #region Gather Build Data

            if (buildInfo.IsCommandLine)
            {
                ParseBuildCommandLine(ref buildInfo);
            }

            #endregion Gather Build Data

            BuildReport buildReport = UnityPlayerBuildTools.BuildUnityPlayer(buildInfo);

            bool success = buildReport != null && buildReport.summary.result == BuildResult.Succeeded;

            if (success && buildInfo.BuildAppx)
            {
                success &= await UwpAppxBuildTools.BuildAppxAsync(buildInfo);
            }

            return(success);
        }
Exemple #3
0
        private static void ParseBuildCommandLine(ref UwpBuildInfo buildInfo)
        {
            IBuildInfo iBuildInfo = buildInfo;

            UnityPlayerBuildTools.ParseBuildCommandLine(ref iBuildInfo);

            string[] arguments = Environment.GetCommandLineArgs();

            for (int i = 0; i < arguments.Length; ++i)
            {
                switch (arguments[i])
                {
                case "-buildAppx":
                    buildInfo.BuildAppx = true;
                    break;

                case "-rebuildAppx":
                    buildInfo.RebuildAppx = true;
                    break;
                }
            }
        }