monitor resolution vs game resolution unity code example

Example: unity c# change game resolution

using UnityEngine;
public class ExampleScript : MonoBehaviour
{
    void Start()
    {
        // Switch to 640 x 480 full-screen
        Screen.SetResolution(640, 480, true);
        
        // Switch to 640 x 480 full-screen at 60 hz
        Screen.SetResolution(640, 480, true, 60);
        
        // Switch to 800 x 600 windowed
        Screen.SetResolution(800, 600, false);
    }
}

//A resolution switch does not happen immediately;
//it will actually happen when the current frame is finished.