Murtaza Raza
Murtaza Raza

Reputation: 67

Unity windowed mode size is different on different screen resolutions

So I want the window size in the build to be of a certain size and it works great when displayed on 1920 x 1080 screen resolution, anything more or less than that, and the window becomes too big or too small. Is there any way for the window to be of the same window to screen size resolution?

I have used the following settings:

My build settings

Upvotes: 0

Views: 2264

Answers (2)

derHugo
derHugo

Reputation: 90704

Afaik you can set the resolution depending on the Display screen size using Screen.currentResolution and Screen.SetResolution somewhat like e.g.

public class ScreenSizeController : MonoBehaviour
{
    // how much space (percentage) of the screen should your window fill
    [Range(0f,1f)]
    public float fillX;
    [Range(0f,1f)]
    public float fillY;

    private void Awake()
    {
        // Get actual display resolution
        var res = Screen.currentResolution;

        // calculate target resolution using the fill
        var targetX = fillX * res.width;
        var targetY = fillY * res.height;

        // Set player resolution
        Screen.SetResolution(targetX, targetY, false);
    }
}

Note: Typed on smartphone but I hope the idea gets clear

Upvotes: 2

Beanie
Beanie

Reputation: 179

Wouldn't changing the screen width/height in the resolution and presentation menu to 1920 x 1080 fix it

Upvotes: 0

Related Questions