void OnLocateBuildClicked()
        {
            AnalyticsHelper.ButtonClicked(string.Format("{0}_LocateBuild", currentTab));
            string previousBuildPath = ShareUtils.GetFirstValidBuildPath();
            string buildPath         = EditorUtility.OpenFolderPanel("Choose folder", string.IsNullOrEmpty(previousBuildPath) ? Application.persistentDataPath : previousBuildPath, string.Empty);

            if (string.IsNullOrEmpty(buildPath))
            {
                return;
            }
            if (!ShareUtils.BuildIsValid(buildPath))
            {
                Store.Dispatch(new OnErrorAction()
                {
                    errorMsg = "This build is corrupted or missing, please delete it and choose another one to share"
                });
                return;
            }
            ShareUtils.AddBuildDirectory(buildPath);
            if (currentTab != TAB_UPLOAD)
            {
                return;
            }
            SetupUploadTab();
        }
        /// <summary>
        /// Triggers the "Build Game" dialog
        /// </summary>
        /// <returns>True and the build path if everything goes well and the build is done, false and empty string otherwise.</returns>
        public static (bool, string) OpenBuildGameDialog(BuildTarget activeBuildTarget)
        {
            string path = string.Empty;

            try
            {
                string defaultOutputDirectory = ShareUtils.GetFirstValidBuildPath();
                if (string.IsNullOrEmpty(defaultOutputDirectory) && CreateDefaultBuildsFolder)
                {
                    defaultOutputDirectory = DefaultBuildsFolderPath;
                    if (!Directory.Exists(defaultOutputDirectory))
                    {
                        Directory.CreateDirectory(defaultOutputDirectory);
                    }
                }

                path = EditorUtility.SaveFolderPanel("Choose Folder for New WebGL Build", defaultOutputDirectory, "");

                if (string.IsNullOrEmpty(path))
                {
                    return(false, string.Empty);
                }

                BuildPlayerOptions buildOptions = new BuildPlayerOptions();
                buildOptions.scenes           = EditorBuildSettingsScene.GetActiveSceneList(EditorBuildSettings.scenes);
                buildOptions.locationPathName = path;
                buildOptions.options          = BuildOptions.None;
                buildOptions.targetGroup      = BuildPipeline.GetBuildTargetGroup(activeBuildTarget);
                buildOptions.target           = activeBuildTarget;

                buildStartedFromTool = true;
                BuildReport report = BuildPipeline.BuildPlayer(buildOptions);
                buildStartedFromTool = false;

                AnalyticsHelper.BuildCompleted(report.summary.result, report.summary.totalTime);
                switch (report.summary.result)
                {
                case BuildResult.Cancelled:  //Debug.LogWarning("[Version and Build] Build cancelled! " + report.summary.totalTime);
                case BuildResult.Failed:     //Debug.LogError("[Version and Build] Build failed! " + report.summary.totalTime);
                    return(false, string.Empty);

                case BuildResult.Succeeded:   //Debug.Log("[Version and Build] Build succeeded! " + report.summary.totalTime);
                case BuildResult.Unknown:     //Debug.Log("[Version and Build] Unknown build result! " + report.summary.totalTime);
                    break;
                }
            }
            catch (BuildPlayerWindow.BuildMethodException /*e*/)
            {
                //Debug.LogError(e.Message);
                return(false, string.Empty);
            }
            return(true, path);
        }
Beispiel #3
0
        void OnLocateBuildClicked()
        {
            AnalyticsHelper.ButtonClicked(string.Format("{0}_LocateBuild", currentTab));

            string lastBuildPath = ShareUtils.GetFirstValidBuildPath();

            if (string.IsNullOrEmpty(lastBuildPath) && ShareBuildProcessor.CreateDefaultBuildsFolder)
            {
                lastBuildPath = ShareBuildProcessor.DefaultBuildsFolderPath;
                if (!Directory.Exists(lastBuildPath))
                {
                    Directory.CreateDirectory(lastBuildPath);
                }
            }

            string buildPath = EditorUtility.OpenFolderPanel("Choose folder", lastBuildPath, string.Empty);

            if (string.IsNullOrEmpty(buildPath))
            {
                return;
            }
            if (!ShareUtils.BuildIsValid(buildPath))
            {
                Store.Dispatch(new OnErrorAction()
                {
                    errorMsg = "This build is corrupted or missing, please delete it and choose another one to share"
                });
                return;
            }
            ShareUtils.AddBuildDirectory(buildPath);
            if (currentTab != TAB_UPLOAD)
            {
                return;
            }
            SetupUploadTab();
        }