Upload missing building/character/environment assets + refresh stale files (part 4)
443cb74 verified Download Assets/Editor/WindowsBuild.cs from Dido599999/MD111: direct link, hf CLI and curl.
- Browser
- Download file 3.18 kB
-
https://huggingface.co/Dido599999/MD111/resolve/main/Assets/Editor/WindowsBuild.cs
- Command line
-
hf download hf://Dido599999/MD111/Assets/Editor/WindowsBuild.cs
-
curl -L -o WindowsBuild.cs https://huggingface.co/Dido599999/MD111/resolve/main/Assets/Editor/WindowsBuild.cs
3.18 kB
| using System.IO; | |
| using System.Linq; | |
| using UnityEditor; | |
| using UnityEditor.Build; | |
| using UnityEditor.Build.Reporting; | |
| using UnityEngine; | |
| /// <summary> | |
| /// WindowsBuild - produces a real Windows player of the whole 122-scene world | |
| /// so the game can be driven with an actual keyboard. CCSmoke cannot prove | |
| /// movement: in -batchmode the Input System never creates a device, so | |
| /// Keyboard.current is null and SimpleCar.cs:28 returns early before it ever | |
| /// reads W. A windowed player is the only honest test. | |
| /// | |
| /// Mono scripting backend is forced on purpose - IL2CPP needs the (absent) | |
| /// VS Build Tools 2022 C++ toolchain, Mono ships with the editor. | |
| /// | |
| /// Batch (no -quit: the method exits Unity itself so the exit code is the | |
| /// build result): | |
| /// Unity.exe -batchmode -projectPath .. -executeMethod WindowsBuild.Run -logFile build.log | |
| /// </summary> | |
| public static class WindowsBuild | |
| { | |
| const string ExeName = "DiDo111_CC-Game.exe"; | |
| public static void Run() | |
| { | |
| // Mono, or the build dies halfway asking for a C++ toolchain. | |
| PlayerSettings.SetScriptingBackend(NamedBuildTarget.Standalone, ScriptingImplementation.Mono2x); | |
| var scenes = EditorBuildSettings.scenes | |
| .Where(s => s.enabled && !string.IsNullOrEmpty(s.path)) | |
| .Select(s => s.path) | |
| .ToArray(); | |
| if (scenes.Length == 0) | |
| { | |
| Debug.LogError("[WindowsBuild] EditorBuildSettings has no enabled scenes"); | |
| EditorApplication.Exit(1); | |
| return; | |
| } | |
| string dir = Path.Combine(Directory.GetCurrentDirectory(), "Builds", "Windows"); | |
| Directory.CreateDirectory(dir); | |
| string exe = Path.Combine(dir, ExeName); | |
| var opts = new BuildPlayerOptions | |
| { | |
| scenes = scenes, | |
| locationPathName = exe, | |
| target = BuildTarget.StandaloneWindows64, | |
| targetGroup = BuildTargetGroup.Standalone, | |
| options = BuildOptions.None | |
| }; | |
| Debug.Log("[WindowsBuild] target=StandaloneWindows64 scenes=" + scenes.Length + | |
| " backend=Mono out=" + exe); | |
| BuildReport report = BuildPipeline.BuildPlayer(opts); | |
| var s = report.summary; | |
| Debug.Log("[WindowsBuild] result=" + s.result + | |
| " errors=" + s.totalErrors + | |
| " warnings=" + s.totalWarnings + | |
| " sizeBytes=" + s.totalSize + | |
| " timeSec=" + (int)s.totalTime.TotalSeconds + | |
| " out=" + exe); | |
| if (s.result == BuildResult.Succeeded && s.totalErrors == 0) | |
| { | |
| var f = new FileInfo(exe); | |
| Debug.Log("[WindowsBuild] OK " + f.FullName + " " + | |
| (f.Length / (1024.0 * 1024.0)).ToString("F1") + " MB"); | |
| EditorApplication.Exit(0); | |
| } | |
| else | |
| { | |
| foreach (var step in report.steps) | |
| foreach (var msg in step.messages) | |
| if (msg.type == LogType.Error || msg.type == LogType.Exception) | |
| Debug.LogError("[WindowsBuild] " + msg.content); | |
| EditorApplication.Exit(1); | |
| } | |
| } | |
| } | |