Question by
rasslenebenali456 · Nov 26, 2019 at 08:38 PM ·
screen resolution
screen .resolutions returning dublicates
screen .resolutions returning dublicates only when I build the game, how can I fix it? this is my script.
public Dropdown resolutionDropdown;
Resolution[] resolutions;
private void Start()
{
resolutions = Screen.resolutions;
resolutionDropdown.ClearOptions();
List<string> options = new List<string>();
int currentResolutionIndex = 0;
for(int i = 0; i < resolutions.Length; i++)
{
string option = resolutions[i].width + " x " + resolutions[i].height;
options.Add(option);
if (resolutions[i].width == Screen.currentResolution.width &&
resolutions[i].height == Screen.currentResolution.height)
{
currentResolutionIndex = i;
}
}
resolutionDropdown.AddOptions(options);
resolutionDropdown.value = currentResolutionIndex;
resolutionDropdown.RefreshShownValue();
}
public void SetResolution(int resolutionIndex)
{
Resolution resolution = resolutions[resolutionIndex];
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
}
Comment
Are you sure they are duplicates ? I tried it now the line :
resolutions = Screen.resolutions;
And there is no the same resolutions. $$anonymous$$aybe you see same resolutions but not same Hz ? $$anonymous$$y resolutions are all the same Hz 60Hz but maybe on your case it's showing other Hz ?
Your answer
![](https://koobas.hobune.stream/wayback/20220612215330im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Mobile screen resolution 0 Answers
Error with screen resolution on boot up, DX 11, failed switching to resolution 0 Answers
How can I scale UI text per resolution? 0 Answers
Screen SetResolution doesn't stay full screen on Kindle Fire, fine on other android devices. 1 Answer
What is the best/easiest method to scale a 2D mobile game to all screen sizes? 0 Answers