Search Unity

Question Why can't I change Dropdown value(or how do I change Dropdown value)

Discussion in 'Getting Started' started by erikmiculek, Jul 2, 2022.

  1. erikmiculek

    erikmiculek

    Joined:
    Mar 18, 2022
    Posts:
    6
    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.
     
  2. erikmiculek

    erikmiculek

    Joined:
    Mar 18, 2022
    Posts:
    6
    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)
     
  3. RichAllen2023

    RichAllen2023

    Joined:
    Jul 19, 2016
    Posts:
    1,026
    Please use CODE tags when you're displaying code.
     
  4. erikmiculek

    erikmiculek

    Joined:
    Mar 18, 2022
    Posts:
    6
    Is there a place where I can find all possible tags?
     
  5. Kreshi

    Kreshi

    Joined:
    Jan 12, 2015
    Posts:
    446
    The forum has a "Insert Code" button where you can copy&paste your code for automatically adding the CODE tags.