Search Unity

Question Resolution after game restart

Discussion in 'Editor & General Support' started by piraente, Aug 22, 2020.

  1. piraente

    piraente

    Joined:
    Oct 19, 2019
    Posts:
    10
    Hey, after hours of searching through everything google had to offer, I still couldn't find an answer.
    I have created a dropdown UI to select a screen resolution on runtime, this is working fine, but how can I save this setting as default for the next game session?
    Everytime I start the game the resolution is set back to the player settings, only the fullscreen mode is saved by its own.
    I use the Screen.SetResolution() function.

    I tried using the PlayerPrefs to save it manually, but its not working.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Can't say why your PlayerPrefs wasn't working. Saving to PlayerPrefs, then loading from PlayerPrefs on game start and then applying the resolution is the most direct solution.
     
  3. piraente

    piraente

    Joined:
    Oct 19, 2019
    Posts:
    10
    I found the problem, the dropdown was the actual problem. While preselecting the current Resolution it triggers the change function. I really should be more carefull with outdated tutorials. :/

    The Documentation for this really need more explanation, is the default value only for the very first start and after this the normal value is used? Or is it stored somethere else besides the regedit? (I use windows)

    edit: is using Playerpref and loading it at start the recommended way of doing it? Or can I just rely on the setResolution function? (It looks like its working fine now after not using the dropdown)