When I try to change the value of the dropdown to 2 for example it stayes at 0 even though PlayerPrefs.GetInt(“FullScreenType”) = 2
int currentFullscreenTypeValue;
public TMP_Dropdown FullscreenTypeDropdown;
void Start()
{
SetPlayerPrefs();
}
public void SetFullscreen(int fullscreenType)
{
if (fullscreenType == 0) {
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
PlayerPrefs.SetInt(“FullScreenType”, fullscreenType);
}
else if(fullscreenType == 1)
{
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
PlayerPrefs.SetInt(“FullScreenType”, fullscreenType);
}
else
{
Screen.fullScreenMode = FullScreenMode.Windowed;
PlayerPrefs.SetInt(“FullScreenType”, fullscreenType);
}
}
private void SetPlayerPrefs()
{
//FullscreenType
currentFullscreenTypeValue = PlayerPrefs.GetInt(“FullScreenType”);
FullscreenTypeDropdown.value = currentFullscreenTypeValue;
FullscreenTypeDropdown.RefreshShownValue();
}
I have debugged it and the playerpref is 2 but FullscreenTypeDropdown.value is 0 and I dont know why.
I have found out what the problem was I had a different error in my code which for some reason wasnt reported in the console so the part where I changed the value never happened (The error was reported in the console only after restarting unity)
erikmiculek:
When I try to change the value of the dropdown to 2 for example it stayes at 0 even though PlayerPrefs.GetInt(“FullScreenType”) = 2
int currentFullscreenTypeValue;
public TMP_Dropdown FullscreenTypeDropdown;
void Start()
{
SetPlayerPrefs();
}
public void SetFullscreen(int fullscreenType)
{
if (fullscreenType == 0) {
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
PlayerPrefs.SetInt(“FullScreenType”, fullscreenType);
}
else if(fullscreenType == 1)
{
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
PlayerPrefs.SetInt(“FullScreenType”, fullscreenType);
}
else
{
Screen.fullScreenMode = FullScreenMode.Windowed;
PlayerPrefs.SetInt(“FullScreenType”, fullscreenType);
}
}
private void SetPlayerPrefs()
{
//FullscreenType
currentFullscreenTypeValue = PlayerPrefs.GetInt(“FullScreenType”);
FullscreenTypeDropdown.value = currentFullscreenTypeValue;
FullscreenTypeDropdown.RefreshShownValue();
}
I have debugged it and the playerpref is 2 but FullscreenTypeDropdown.value is 0 and I dont know why.
Please use CODE tags when you’re displaying code.
Is there a place where I can find all possible tags?
Kreshi
July 4, 2022, 11:12pm
5
The forum has a “Insert Code” button where you can copy&paste your code for automatically adding the CODE tags.