Question by
ilbailba · Aug 16, 2021 at 09:36 PM ·
settingsqualityresolutions
My graphics setting is not working properly!
Hello to everyone. I'm ilyas. The change I made to the game recently is causing problems during the build phase.
the thing is; I recently added a resolution setting to the game. and I worked hard for it. but when I added the "hz" setting to the game in a way that I don't know how, the game started to ignore the resolution setting. Even if the resolution is 1920 by 1080 (16' by 9) my screen looks like a 3:4 ratio. Meanwhile; my window settings are not "resizable". (in-game image)
here is the code i wrote =
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
public class SettingMenu : MonoBehaviour
{
public AudioMixer audioMixer;
public TMPro.TMP_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 //+ " (@" + Screen.currentResolution.refreshRate + " Hz)";
if(options.Contains(option))
continue;
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);
}
public void SetVolume(float volume)
{
audioMixer.SetFloat("volume", volume);
}
public void SetQuality (int qualityIndex)
{
QualitySettings.SetQualityLevel(qualityIndex);
}
public void SetFullScreen(bool isFullscreen)
{
Screen.fullScreen = isFullscreen;
}
}
[1]: https://imgur.com/a/SIUwBVN
Comment
Your answer
Follow this Question
Related Questions
Why baked lights are so poor quality?? 0 Answers
Cycling through visual quality levels. 0 Answers
How do i reset to the defualt Camera setting(Unity3d) 1 Answer
Can't make game windowed. 0 Answers