Skip to content

Commit

Permalink
Maroon-579 Add Confirm dialogue to Build for All option (#580)
Browse files Browse the repository at this point in the history
* Add Confirm script before long builds

* Add the possibility to disable sceneValidationTests during Build
  • Loading branch information
FlorianGlawogger authored Feb 13, 2025
1 parent 438f61c commit a8dc22d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
19 changes: 16 additions & 3 deletions unity/Assets/Maroon/Editor/BuildPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ public static void BuildExperimentsWebGL()
[MenuItem("Maroon Build/All Platforms, Conventional and Standalone")]
public static void BuildAll()
{
var buildPath = EditorUtility.SaveFolderPanel("Choose Build Location", string.Empty, "Build");
bool confirmed = EditorUtility.DisplayDialog("Build for ALL?",
"Are you sure you want to build everything?\n" +
"This includes a build for the Laboratory version as well as ALL standalone versions, for ALL platforms.",
"Yes, build everything", "Cancel");
if (!confirmed)
return;

var buildPath = EditorUtility.SaveFolderPanel("Choose Build Location (All Platforms, Conventional and Standalone)", string.Empty, "Build");

if (buildPath.Length == 0)
{
Expand All @@ -126,7 +133,7 @@ private static void BuildConventionalMaroon(MaroonBuildTarget buildTarget, strin
return;
}

buildPath = EditorUtility.SaveFolderPanel("Choose Build Location", "Build", "Laboratory");
buildPath = EditorUtility.SaveFolderPanel("Choose Build Location (Conventional Maroon)", "Build", "Laboratory");

if(buildPath.Length == 0)
{
Expand Down Expand Up @@ -179,8 +186,14 @@ private static void BuildStandaloneExperiments(MaroonBuildTarget buildTarget, st
{
return;
}
bool confirmed = EditorUtility.DisplayDialog("Build Standalone Experiments?",
"Are you sure you build all Standalone Experiments?\n" +
"This will create a separate build for EACH experiment. If you want to create one build that includes all experiments, choose \"Conventional Maroon\"",
"Yes, build standalone experiments", "Cancel");
if (!confirmed)
return;

buildPath = EditorUtility.SaveFolderPanel("Choose Build Location", "Build", "Experiments");
buildPath = EditorUtility.SaveFolderPanel("Choose Build Location (Standalone Experiments)", "Build", "Experiments");

if (buildPath.Length == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,38 @@ namespace Tests.EditModeTests.ContentValidation
/// The build process stops if any test should fail and a popup with all failed tests is shown.
/// </summary>
/// <remarks>
/// To disable the tests during build, simply comment out the entire class :)
/// To disable the tests during build, in the Unity Editor select "Maroon Build" -> "Settings" -> "ENABLE/DISABLE SceneValidationTests during Build"
/// </remarks>
public class RunSceneValidationTestsDuringBuild : IProcessSceneWithReport
{
private static bool doRunSceneValidationTestsDuringBuild = true;
public int callbackOrder => 0;
private readonly Regex _experimentNameRegex = new Regex(@"\w+\.(pc|vr)");

[MenuItem("Maroon Build/Settings/ENABLE SceneValidationTests during Build", priority = 101)]
static void TurnOnSceneValidationTests()
{
doRunSceneValidationTestsDuringBuild = true;
Debug.Log("Running SceneValidationTests during Build has been ENABLED.");
}

[MenuItem("Maroon Build/Settings/DISABLE SceneValidationTests during Build", priority = 100)]
static void TurnOffSceneValidationTests()
{
doRunSceneValidationTestsDuringBuild = false;
Debug.Log("Running SceneValidationTests during Build has been DISABLED.");
}

public void OnProcessScene(Scene scene, BuildReport report)
{
// Don't execute scene validation tests during playmode
if (report == null)
return;

// Skip SceneValidation tests if turned off
if (!doRunSceneValidationTestsDuringBuild)
return;

var scenePath = scene.path;

// Call RunSceneTests delayed, otherwise Unity version 2022 crashes
Expand Down

0 comments on commit a8dc22d

Please sign in to comment.