- Home /
Unable to assign a dropdown variable in the inspector
Im doing a settings menu tutorial by Brackeys but for some reason by the "resolution dropdown" part I cant insert anything into the box :/ Script: {
public AudioMixer audioMixer;
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 SetVolume(float volume)
{
audioMixer.SetFloat("volume", volume);
}
public void SetQuality(int qualityIndex)
{
QualitySettings.SetQualityLevel(qualityIndex);
}
public void SetFullScreen(bool isFullscreen)
{
Screen.fullScreen = isFullscreen;
}
}
anything wrong? is it possibly because I have an older version of unity?
Answer by mikaxms · Mar 31, 2020 at 07:43 PM
I had the same issue, but for a different reason. My mistake was that I was using a TMPro Dropdown and had a variable for a standard Dropdown. I would recommend checking that as well, if someone has a similar issue.
Answer by ArseneySorokin · Sep 27, 2018 at 11:16 AM
Try dragging the "ResolutionOption" GameObject directly into this variable. Make sure it really has a "DropDown" component on it. If that doesn't work, please post a screenshot of the "ResolutionOption" GameObject.
Answer by LionN00b · Oct 18, 2018 at 02:08 AM
@ArseneySorokin I fixed it, it must have been a glitch, all i did was redo the whole dropdown
Answer by ilbailba · Aug 15, 2021 at 02:10 PM
Hello there! I just had this problem too and we watched the same training with you. I just found the solution and wanted to share it with you.
public Dropdown resolutionDropdown;
in your code instead of
public TMPro.TMP_Dropdown resolutionDropdown;
Just write!
Your answer
Follow this Question
Related Questions
Reading variable from other script 1 Answer
Variable References in C# from JS 1 Answer
Subtract variable value in certain seconds 1 Answer
Decrease a value over time when W is pressed. 2 Answers
What is typed variable? 2 Answers