- Home /
Question by
zafranalon · Oct 22, 2021 at 09:17 AM ·
uiresolutionsettingsdropdownduplicate
Unity resolution dropdown duplicating
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
public class SettingsPanel : MonoBehaviour
{
public AudioMixer mainMixer;
Resolution[] resolutions;
public Dropdown dd;
// Start is called before the first frame update
void Start()
{
resolutions = Screen.resolutions;
dd.ClearOptions();
List<string> options = new List<string>();
int currentResIndex = 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)
{
currentResIndex = i;
}
}
dd.AddOptions(options);
dd.value = currentResIndex;
dd.RefreshShownValue();
List<Resolution> uniqueResolutions = new List<Resolution>();
}
public void setRes(int resIndex)
{
Resolution resolution = resolutions[resIndex];
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
}
// Update is called once per frame
void Update()
{
}
public void ChangeQuality(int qualityIndex)
{
QualitySettings.SetQualityLevel(qualityIndex);
}
public void SetFullScreen(bool isFullScreen)
{
Screen.fullScreen = isFullScreen;
}
public void SetVolume(float volume)
{
mainMixer.SetFloat("volume", volume);
}
}
For some reason the values are duplicating but only in build
Comment
Your answer
Follow this Question
Related Questions
Remove specific screen resolutions 0 Answers
how to save the resolutions for the options menu 1 Answer
Trying to Get Our Resolution Settings to Start on the Current Resolution of the Player's Computer 0 Answers
New Unity Dropdown Menu to Change Game Resolution 1 Answer
How to save the resolution of screen between scenes 2 Answers