UE4中窗口模式切换

1、设置游戏启动的默认窗口模式

       设置默认模式可通过修改配置文件的方式,配置文件名DefaultGameUserSettings.ini,位于Config目录下,如果没有该文件可新建一个,配置项如下

[/Script/Engine.GameUserSettings]
 bUseVSync=False
 ResolutionSizeX=1280
 ResolutionSizeY=720
 LastUserConfirmedResolutionSizeX=1280
 LastUserConfirmedResolutionSizeY=720
 WindowPosX=-1
 WindowPosY=-1
 bUseDesktopResolutionForFullscreen=True
 FullscreenMode=2
 LastConfirmedFullscreenMode=2

修改FullscreenMode的值可设置为全屏或窗口模式,0表示全屏模式,1表示窗口全屏模式,2表示窗口模式,UE4中定义为

UENUM(BlueprintType)
namespace EWindowMode
{
    enum Type
    {
        /** The window is in true fullscreen mode */
        Fullscreen,
        /** The window has no border and takes up the entire area of the screen */
        WindowedFullscreen,
        /** The window has a border and may not take up the entire screen area */
        Windowed,
    };
}

修改ResolutionSizeX和ResolutionSizeY,可设置窗口分辨率

 

2、运行中切换窗口模式

       游戏运行中可通过UGameUserSettings类实现窗口模式切换

void SetFullScreenMode(bool bFull)
{
    if (bFull)
	{
		UGameUserSettings::GetGameUserSettings()->SetFullscreenMode(EWindowMode::WindowedFullscreen);//或者EWindowMode::Fullscreen
	}
	else
	{
		UGameUserSettings::GetGameUserSettings()->SetFullscreenMode(EWindowMode::Windowed);
	}
	UGameUserSettings::GetGameUserSettings()->ApplyResolutionSettings(false);
}

3、通过命令行模式启动窗口或全屏模式。以下为官方文档对部分命令行参数的说明:

ConsoleX: Horizontal position for console output window.

ConsoleY: Vertical position for console output window.

WinX: Set the horizontal position of the game window on the screen.

WinY: Set the vertical position of the game window on the screen.

ResX: Set horizontal resolution for game window.

ResY: Set vertical resolution for game window.

VSync: Activate the VSYNC via command line. (prevents tearing of the image but costs fps and causes input latency)

NoVSync: Deactivate the VSYNC via command line

BENCHMARK: Run game at fixed-step in order to process each frame without skipping any frames. This is useful in conjunction with DUMPMOVIE options.

DUMPMOVIE: Dump rendered frames to files using current resolution of game.

EXEC: Executes the specified exec file.

FPS: Set the frames per second for benchmarking.

FULLSCREEN: Set game to run in fullscreen mode.

SECONDS: Set the maximum tick time.

WINDOWED: Set game to run in windowed mode.

启动窗口模式命令行参数 -WINDOWED -ResX=1280 -ResY=720

启动全屏模式命令行参数 -FULLSCREEN

以命令行参数启动有下面两种方式启动:

(1)将WindowsNoEditor下的exe文件创建快捷方式

UE4中窗口模式切换_第1张图片

并在快捷方式属性中添加命令行参数,然后以快捷方式启动程序即可。

UE4中窗口模式切换_第2张图片

(2)在WindowsNoEditor下新建一个文本文档,重命名为run.bat,打开文件编辑内容如下,然后运行run.bat即可。

start ThirdPerson.exe -WINDOWED -ResX=1280 -ResY=720

 

 

你可能感兴趣的:(Unreal,Engine)