How to set resolution in unity

introduce

To set the game resolution in Unity (final release), there are two methods:


Set game resolution via code

void Start()
{
    
    
    Screen.SetResolution(1920, 1080, true); // 这里设置分辨率为1920*1080,并以全屏模式执行
}

Among them, the Screen.SetResolution() function is used to set the resolution of the game, and the meanings of the parameters are width, height and full screen or not. It should be noted that using a fixed resolution on different devices may cause distortion or deformation of the display effect, so it is best to make adaptive adjustments according to the needs of specific devices and games.


Manually set the game resolution via the editor panel

The game resolution can be set manually in Unity's editor panel. Methods as below:

First, select "File" -> "Build Settings", open the "Build Settings" window, click the "Player Settings" button in this window, open the "Player Settings" panel, and then select the "Resolution and Presentation" tab, here you can Set the game window size, so as to achieve the purpose of setting the game resolution.

It should be noted that when running a Unity game on the PC side, it can support multiple forms of expression such as full-screen mode, window mode, and WebGL, so it needs to be flexibly selected according to actual needs. Games running on mobile devices need to be adapted according to factors such as the screen resolution and aspect ratio of the device to ensure game performance and user experience.


Guess you like

Origin blog.csdn.net/qq_20179331/article/details/130232824