- Home /
 
Resolution is not saving.
I am having a problem with the resolution. The resolution is not saved. When I close the game and reopen it at first it opens fine and suddenly it changes to a default resolution and I have to change it again. I do not understand what is wrong in the code that the resolution is not saved. I already tried a thousand ways and I can't solve it. Here is the code that I am using to change the resolution and save it:
 public class LogicResolution : MonoBehaviour
 {
     public TMP_Dropdown resolutionsDropDown;
     public int optionIndex;
  
     void Start()
     {
         optionIndex = PlayerPrefs.GetInt("resolutionNumber", 2);
         resolutionsDropDown.value = optionIndex;
         AdjustResolution();    
     }
  
     public void AdjustResolution()
     {          
         if (resolutionsDropDown.value == 0)
             Screen.SetResolution(640, 360, Screen.fullScreen);
         else if (resolutionsDropDown.value == 1)
             Screen.SetResolution(1280, 720, Screen.fullScreen);
         else if (resolutionsDropDown.value == 2)
             Screen.SetResolution(1920, 1080, Screen.fullScreen);
         else if (resolutionsDropDown.value == 3)
             Screen.SetResolution(3840, 2160, Screen.fullScreen);
  
         PlayerPrefs.SetInt("resolutionNumber", resolutionsDropDown.value);
         optionIndex = resolutionsDropDown.value;    
     }
 
               The default value is 1280x720 when I actually set it to start with 1920x1080.
Answer by rh_galaxy · Apr 07, 2021 at 03:59 AM
You need to run this to make it stick.
 PlayerPrefs.Save();
 
              Answer by JackReivaj · Apr 07, 2021 at 04:34 AM
@rh_galaxy I added that, but it doesn't save anyway.
Your answer
 
             Follow this Question
Related Questions
Unity Resolution Limit 2 Answers
How to save the resolution of screen between scenes 2 Answers
Standard Asset joystick has issues when using custom resolution 1 Answer
Resolutions duplicates in options menu 0 Answers
Resolution being saved as 0x0 0 Answers