Wzrd
Wzrd

Reputation: 258

Resolution changes once program is built

I am creating a Unity project in the 1920x1080 resolution (the same as my monitor). Everything looks fine when testing the program in the Unity editor - however, once built the resolution changes to an unusable state.

I have an option to change the resolution, however, I don't think this is the problem as the resolution is messed up before even changing the setting.

Screenshots: In Unity , Built

Here are some snippets of code which could be the cause of the problem if I've over looked something. The code is from this tutorial.

void Start ()
{
     resolutions = Screen.resolutions;
     currentResolutionIndex = PlayerPrefs.GetInt(RESOLUTION_PREF_KEY, 0);
     SetResolutionText(resolutions[currentResolutionIndex]);
}
private void SetAndApplyResolution(int newResolutionIndex)
{
     currentResolutionIndex = newResolutionIndex;
     ApplyCurrentResolution();
}

private void ApplyCurrentResolution()
{
     ApplyResolution(resolutions[currentResolutionIndex]);
}

private void ApplyResolution(Resolution resolution)
{
     SetResolutionText(resolution);
     Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
     PlayerPrefs.SetInt(RESOLUTION_PREF_KEY, currentResolutionIndex);
}

Upvotes: 0

Views: 3103

Answers (3)

Wzrd
Wzrd

Reputation: 258

To solve the problem, I've just used Unity's inbuilt 'display resolution dialogue'.

This may seem a little lazy, however, it's solved the problem perfectly and also offers graphics option changes.

Maybe in the future, I'll come back and incorporate resolution settings, but as of now the short popup before launching the game is fine.

Upvotes: -1

Darshan Soni
Darshan Soni

Reputation: 329

You can set the resolution via script in Start() and write this line Screen.SetResolution(1920,1080,false); that will be set you default resolution to 1920*1080. try this one i hope this will help you.

Upvotes: 1

Eliasar
Eliasar

Reputation: 1074

You need to set the resolution in the Resolution and Presentation section of the Standalone Player settings

You will be able to set how the window will display when opening up from a standalone build.

Upvotes: 3

Related Questions