Resolution does not change when the DropdownMenu option is selected in build.
Hey guys, I browsed the internet to find the solution to my problem but it's totally a goner. I have created a MainMenu and OptionsMenu - which contains volume, resolution, and graphics. Everything apart from the resolution works perfectly. The dropdown resolution menu works but selecting and locking it in the label section of the dropdown, but for some reason, the screen resolution does not change according to the selected screen I am not experienced with code that much, but I understand the basics. Here's the code
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Audio; using UnityEngine.UI; using TMPro; public class SettingsMenu : MonoBehaviour {
public AudioMixer audioMixer;
public TMP_Dropdown resolutionDropdown;
Resolution[] resolutions;
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 + " " + resolutions[i].refreshRate + "Hz";
options.Add(option);
if (resolutions[i].width == Screen.currentResolution.width && resolutions[i].height == Screen.currentResolution.height && resolutions[i].refreshRate == Screen.currentResolution.refreshRate)
{
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, resolution.refreshRate);
}
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;
}
}
Your answer
Follow this Question
Related Questions
parsing error 1 Answer
WTF does this error mean 1 Answer
BCE0044: expecting ''', found '\r'. 1 Answer