diff --git a/UnityLauncherPro/MainWindow.xaml b/UnityLauncherPro/MainWindow.xaml index 49083d2..60e54d0 100644 --- a/UnityLauncherPro/MainWindow.xaml +++ b/UnityLauncherPro/MainWindow.xaml @@ -227,6 +227,7 @@ + diff --git a/UnityLauncherPro/MainWindow.xaml.cs b/UnityLauncherPro/MainWindow.xaml.cs index 5bce4e5..f46d689 100644 --- a/UnityLauncherPro/MainWindow.xaml.cs +++ b/UnityLauncherPro/MainWindow.xaml.cs @@ -3226,6 +3226,12 @@ private void MenuBatchBuildIOS_Click(object sender, RoutedEventArgs e) Tools.BuildProject(proj, Platform.iOS); } + private void MenuBatchBuildCustom_Click(object sender, RoutedEventArgs e) + { + var proj = GetSelectedProject(); + Tools.BuildProjectCustom(proj); + } + private void ChkCheckPlasticBranch_Checked(object sender, RoutedEventArgs e) { if (this.IsActive == false) return; // dont run code on window init diff --git a/UnityLauncherPro/Tools.cs b/UnityLauncherPro/Tools.cs index 861f5e6..8dddfee 100644 --- a/UnityLauncherPro/Tools.cs +++ b/UnityLauncherPro/Tools.cs @@ -2104,7 +2104,34 @@ static string[] GetScenes() } - // runs unity SimpleWebServer.exe and launches default Browser into project build/ folder' + public static void BuildProjectCustom(Project proj) + { + Console.WriteLine("Building " + proj.Title + " (custom)"); + SetStatus("Build process started: " + DateTime.Now.ToString("HH:mm:ss")); + + // get selected project unity exe path + var unityExePath = Tools.GetUnityExePath(proj.Version); + if (unityExePath == null) return; + + // create commandline string for building and launch it + //var buildcmd = $"\"{unityExePath}\" -quit -batchmode -nographics -projectPath \"{proj.Path}\" -executeMethod \"Builder.BuildAndroid\" -buildTarget android -logFile -"; + // TODO test without nographics : https://forum.unity.com/threads/batch-build-one-scene-is-black-works-in-normal-file-build.1282823/#post-9456524 + var buildParams = $" -quit -batchmode -nographics -projectPath \"{proj.Path}\" -executeMethod \"UnityLauncherProToolsCustom.BuildCustom\""; + Console.WriteLine("buildcmd= " + buildParams); + + // launch build + var proc = Tools.LaunchExe(unityExePath, buildParams); + + // wait for process exit then open output folder + proc.Exited += (o, i) => + { + SetStatus("Build process finished: " + DateTime.Now.ToString("HH:mm:ss")); + // TODO set color based on results + SetBuildStatus(Colors.Green); + }; + } + + // runs unity SimpleWebServer.exe and launches default Browser into project build/ folder' public static void LaunchWebGL(Project proj, string relativeFolder) { var projPath = proj?.Path.Replace('/', '\\');