public static void killProcesses() { GameLauncherSettings gls = GameObject.FindObjectOfType <GameLauncherSettings>(); if (gls) { if (gls.enterPlayMode && EditorApplication.isPlaying) { EditorApplication.ExitPlaymode(); } } string gameProcName = PlayerSettings.productName; //Find valid processes of this game Process.GetProcesses().ToList().FindAll( proc => { try { return(!proc.HasExited && proc.ProcessName == gameProcName); } catch { return(false); } }) //And then kill them .ForEach(proc => proc.Kill()); }
public static void runWindows() {//2018-08-10: copied from build() int windowCount = 1; GameLauncherSettings gls = GameObject.FindObjectOfType <GameLauncherSettings>(); if (gls) { windowCount = gls.clientCount; if (gls.resetClients) { killProcesses(); } } else { Debug.LogWarning( "No GameLauncherSettings object found!" + " Make a new one or open up the Tools scene to make this tool more useful." ); } string extension = "exe"; string buildName = getBuildNamePath(extension); Debug.Log($"Launching: {buildName}"); for (int i = 0; i < windowCount; i++) { // Run the game (Process class from System.Diagnostics). Process proc = new Process(); proc.StartInfo.FileName = buildName; proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal; proc.Start(); } }
public static void testWindows() { runWindows(); GameLauncherSettings gls = GameObject.FindObjectOfType <GameLauncherSettings>(); if (gls) { if (gls.enterPlayMode) { EditorApplication.EnterPlaymode(); } } }