#if UNITY_EDITOR using UnityEditor; using UnityEditor.Build.Reporting; using UnityEngine; namespace ProjectM.EditorTools { /// /// One-click Windows player build + the "Boot Into Menu (Editor)" toggle that flips GameBootstrap into the /// frontend path for in-editor menu testing (shared EditorPrefs key "ProjectM.BootIntoMenu"). Lives in the /// special Editor folder (compiles into Assembly-CSharp-Editor) so it needs no ProjectM asmdef references. /// public static class BuildTool { const string BootPrefKey = "ProjectM.BootIntoMenu"; const string BootMenuItem = "ProjectM/Boot Into Menu (Editor)"; [MenuItem("ProjectM/Build/Windows Player")] public static void BuildWindows() { string[] scenes = { "Assets/Scenes/MainMenu.unity", "Assets/Scenes/Game.unity", }; const string dir = "Builds/Windows"; System.IO.Directory.CreateDirectory(dir); var options = new BuildPlayerOptions { scenes = scenes, locationPathName = System.IO.Path.Combine(dir, "ProjectM.exe"), target = BuildTarget.StandaloneWindows64, options = BuildOptions.None, }; BuildReport report = BuildPipeline.BuildPlayer(options); BuildSummary s = report.summary; if (s.result == BuildResult.Succeeded) Debug.Log($"[BuildTool] Build succeeded: ~{s.totalSize / (1024 * 1024)} MB -> {options.locationPathName}"); else Debug.LogError($"[BuildTool] Build {s.result}: {s.totalErrors} error(s)."); } [MenuItem(BootMenuItem)] public static void ToggleBootMenu() { bool v = !EditorPrefs.GetBool(BootPrefKey, false); EditorPrefs.SetBool(BootPrefKey, v); Debug.Log($"[BuildTool] Boot Into Menu (Editor) = {v}. " + (v ? "Open MainMenu.unity and Play to test the menu." : "Normal instant-play / MPPM loop restored.")); } [MenuItem(BootMenuItem, true)] public static bool ToggleBootMenuValidate() { Menu.SetChecked(BootMenuItem, EditorPrefs.GetBool(BootPrefKey, false)); return true; } } } #endif