# SetResolution

> Sets the resolution of the window.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Windowing](/engine/6000.7/script-reference/unityengine/windowing.md)
* **Assembly:** UnityEngine.WindowingModule

## SetResolution(int, int)

Sets the resolution of the window.

```csharp
public AsyncOperation SetResolution(int width, int height)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new width of the window in pixels.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new height of the window in pixels.

### Returns

| Type                                                                            | Description                                                                                                       |
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| [AsyncOperation](/engine/6000.7/script-reference/unityengine/asyncoperation.md) | An [AsyncOperation](/engine/6000.7/script-reference/unityengine/asyncoperation.md) that represents the operation. |

### Remarks

If the window's FullScreenMode is Windowed, the window is resized to match the specified resolution, and the rendering resolution is set accordingly. If the FullScreenMode is maximized or fullscreen, the window occupies the entire screen and the rendering resolution is set to the specified values, which may cause the image to be upscaled or downscaled if the resolution does not match the screen size.

### Examples

```csharp
using UnityEngine;
using UnityEngine.Windowing;

public class SetResolutionExample : MonoBehaviour
{
    AsyncOperation asyncOperation = null;

    void Start()
    {
        var window = GameWindow.Main;
        asyncOperation = window.SetResolution(1280, 720);
    }

    void Update()
    {
        if (asyncOperation != null && asyncOperation.isDone)
        {
            Debug.Log("Window resolution set successfully.");
            asyncOperation = null;
        }
    }
}
```

## SetResolution(int, int, FullScreenMode)

Sets the resolution and full-screen mode of the window.

```csharp
public AsyncOperation SetResolution(int width, int height, FullScreenMode fullScreenMode)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new width of the window in pixels.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new height of the window in pixels.**** (\[FullScreenMode]\(/engine/6000.7/script-reference/unityengine/fullscreenmode)): The new [FullScreenMode](/engine/6000.7/script-reference/unityengine/fullscreenmode.md) for the window.

### Returns

| Type                                                                            | Description                                                                                                       |
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| [AsyncOperation](/engine/6000.7/script-reference/unityengine/asyncoperation.md) | An [AsyncOperation](/engine/6000.7/script-reference/unityengine/asyncoperation.md) that represents the operation. |

### Examples

```csharp
using UnityEngine;
using UnityEngine.Windowing;

public class SetResolutionFullScreenExample : MonoBehaviour
{
    AsyncOperation asyncOperation = null;

    void Start()
    {
        var window = GameWindow.Main;
        asyncOperation = window.SetResolution(1920, 1080, FullScreenMode.FullScreenWindow);
    }

    void Update()
    {
        if (asyncOperation != null && asyncOperation.isDone)
        {
            Debug.Log("Window resolution and full-screen mode set successfully.");
            asyncOperation = null;
        }
    }
}
```

## SetResolution(int, int, FullScreenMode, RefreshRate)

Sets the resolution, full-screen mode, and preferred refresh rate of the window.

```csharp
public AsyncOperation SetResolution(int width, int height, FullScreenMode fullScreenMode, RefreshRate preferredRefreshRate)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new width of the window in pixels.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The new height of the window in pixels.**** (\[FullScreenMode]\(/engine/6000.7/script-reference/unityengine/fullscreenmode)): The new  for the window.**** (\[RefreshRate]\(/engine/6000.7/script-reference/unityengine/refreshrate)): The preferred refresh rate for the window.

### Returns

| Type                                                                            | Description                                                                                                       |
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| [AsyncOperation](/engine/6000.7/script-reference/unityengine/asyncoperation.md) | An [AsyncOperation](/engine/6000.7/script-reference/unityengine/asyncoperation.md) that represents the operation. |

### Examples

```csharp
using UnityEngine;
using UnityEngine.Windowing;

public class SetResolutionRefreshRateExample : MonoBehaviour
{
    AsyncOperation asyncOperation = null;

    void Start()
    {
        var window = GameWindow.Main;
        asyncOperation = window.SetResolution(1920, 1080, FullScreenMode.ExclusiveFullScreen, new RefreshRate{ numerator = 60, denominator = 1 });
    }

    void Update()
    {
        if (asyncOperation != null && asyncOperation.isDone)
        {
            Debug.Log("Window resolution, full-screen mode, and refresh rate set successfully.");
            asyncOperation = null;
        }
    }
}
```
