private static void PANIK() { List <string> results = ScreenInfo.GetScreenInfoList(); string cmdInput = ""; foreach (string r in results) { if (r.StartsWith("0x")) { cmdInput += $"& cmdow {r.Split(' ')[0]} /not /siz 800 600 /mov 0 0 "; } } using (Process t = new Process()) { t.StartInfo.FileName = @"C:\Windows\System32\cmd.exe"; t.StartInfo.Arguments = "/k"; t.StartInfo.UseShellExecute = false; t.StartInfo.RedirectStandardInput = true; t.StartInfo.CreateNoWindow = true; t.Start(); t.StandardInput.WriteLine($@"cd {Application.dataPath}/cmdow/ {cmdInput}& exit"); } isFullScreen = false; Debug.LogWarning($"<b>[cmdow PANIK!]</b> All Game windows(if there has any) are set to:\n" + $"<b><i>Position</i></b>(Main Screen) 0 0\n" + $"<b><i>Size</i></b> 800 600"); }
private static void Refresh(bool s_mode = false) { List <string> results = ScreenInfo.GetScreenInfoList(); int windows = 0; foreach (string r in results) { if (r.StartsWith("0x")) { windows++; } } switch (windows) { case 0: isAvailable = ACGW_bool; if (s_mode) { break; } if (isAvailable) { Debug.LogWarning($"<b>[cmdow Refresh]</b> cmdow has warning:" + $"cmdow does not detect any deteched Game window, but \"Auto Create Game Window\" is checked" + $"FullScreen function will still work if cmdow detect 0 deteched Game window"); } else { Debug.LogError($"<b>[cmdow Refresh]</b> cmdow has error: \n" + $"1. Check if there has any Game window that is deteched from the main Unity Editor.\n" + $"2. The current version Unity Editor is not supported.\n" + $"3. The current version Unity Editor has renamed the Game window title, please wait for update or using cmdow to find the currect window title"); } break; case 1: isAvailable = true; if (s_mode) { break; } Debug.Log($"<b>[cmdow Refresh]</b> cmdow has detect the Game window. FullScreen is now available"); break; default: isAvailable = false; if (s_mode) { break; } Debug.LogWarning($"<b>[cmdow Refresh]</b> The current script does not support more then one deteched Game window"); break; } }
private static async void FullScreen() { Refresh(false); if (!isAvailable) { Debug.LogError("<b>[cmdow FullScreen]</b> cmdow is currently not available, please try Refresh(Control + F12)"); return; } if (ScreenInfo.GetScreenInfoList().Count != 1) { if (ScreenInfo.GetGameWindow() != null) { ScreenInfo.KillAllGameWindow(); } EditorApplication.ExecuteMenuItem("Window/General/Game"); isFullScreen = false; } int gsil = ScreenInfo.GetScreenInfoList().Count; while (gsil == 0) { await Task.Delay(1); gsil = ScreenInfo.GetScreenInfoList().Count; } //3. check if window is fullscreen ScreenInfo si = ScreenInfo.Resolve(ScreenInfo.GetScreenInfoList()[0]); if (si.Size == FS_Size && si.Position == FS_Position) { isFullScreen = true; } else { isFullScreen = false; PFS_Size = si.Size; PFS_Position = si.Position; } using (Process p = new Process()) { p.StartInfo.FileName = @"C:\Windows\System32\cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.CreateNoWindow = true; p.Start(); if (isFullScreen) { //this line is call cmdow to resize deteched game window Debug.Log($"exit play mode: pfs {PFS_Position} {PFS_Size}"); p.StandardInput.WriteLine($@"cd {Application.dataPath}/cmdow/ & cmdow Game /siz {PFS_Size.x} {PFS_Size.y} /mov {PFS_Position.x} {PFS_Position.y} & exit"); isFullScreen = false; } else { //this line is call cmdow to fullscreen deteched game window Debug.Log($"Enter play mode: fs {FS_Position} {FS_Size}"); p.StandardInput.WriteLine($@"cd {Application.dataPath}/cmdow/ & cmdow Game /siz {FS_Size.x} {FS_Size.y} /mov {FS_Position.x} {FS_Position.y} & exit"); isFullScreen = true; } p.StandardInput.AutoFlush = true; p.Close(); } }