Ejemplo n.º 1
0
    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();
        }
    }