Question by
SalviCalvillo · Jun 24, 2019 at 12:13 PM ·
textmeshdropdownrefresh
TextMeshPro Dropdown RefreshValue not working
Hey, I'm trying to make a resolution selector by using the TextMeshPro dropdown. It works as intended but when I initiate it, it always says the resolution is 4K even thought it is not. Everytime the menu where the dropdown is located is activated, I go through all options to check which one is the correct to select the value. When I instantiate I make sure that the only options in the dropdowns are the ones I need.
void Awake()
{
myself = this.GetComponent<UnityEngine.EventSystems.EventSystem>();
resolutionDropdown.ClearOptions();
resolutions[0].width = 640;
resolutions[0].height = 360;
resolutions[1].width = 960;
resolutions[1].height = 540;
resolutions[2].width = 1280;
resolutions[2].height = 720;
resolutions[3].width = 1920;
resolutions[3].height = 1080;
resolutions[4].width = 3840;
resolutions[4].height = 2160;
List<string> rezOpt = new List<string>();
for (int i = 0; i < resolutions.Length; i++)
{
rezOpt.Add(resolutions[i].width + " x " + resolutions[i].height);
}
resolutionDropdown.AddOptions(rezOpt);
}
Then, everytime I enable It I try to get the current position
for(int i = 0; i < 5; i++)
{
Debug.Log(resolutions[i]);
if (resolutions[i].width == Screen.currentResolution.width &&
resolutions[i].height == Screen.currentResolution.height)
{
resolutionDropdown.value = i;
resolutionDropdown.RefreshShownValue();
}
}
And it doesn't mater my screen resolution because when I open the menu it always says (3840x2160) I made sure the screen resolution is equal to the dropdown options so it's sure to enter to the if statement correctly
Comment