Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can I let Android user to choose Quality

Discussion in 'General Discussion' started by mfatihbarut, Jan 20, 2021.

  1. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    Hi all,
    You know unity player has settings before starting the game for quality but there is no such a thing for mobile platforms (as far as I see)
    Is there any option approach for developer to let Android users to choose game graphic quality
     
  2. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,549
    Joe-Censored likes this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I save the quality level to PlayerPrefs. On load of the build, read it back from PlayerPrefs, and if it exists then set quality to that value (if not there, then leave quality at default). As far as the UI for the player to select between, see any UI tutorial. I like using a slider which jumps between ints, but you can implement it a variety of ways.
     
  4. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,965
    Unity should be doing this automatically with a key named "UnityGraphicsQuality".
     
    Joe-Censored likes this.
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You're correct, but only so long as the game doesn't crash or otherwise have its task ended uncleanly. I don't know about you, but it always irritates me whenever I play a game, save some options, then a few hours later the game crashes, and I find I have to set all the options again since they weren't really saved when I thought they were.

    (I'm pretty sure the quality setting is saved automatically on exit, not when the change occurs)
     
    MadeFromPolygons likes this.
  7. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Joe-Censored and Havyx like this.
  8. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    If it's via PlayerPrefs I believe that's the intent - it saves on exit, or you call PlayerPrefs.Save() if you specifically want it to save at other times.

    In an options menu or similar I'd consider calling Save after every change.
     
    FrankenCreations and Cromfeli like this.
  9. FrankenCreations

    FrankenCreations

    Joined:
    Jun 14, 2017
    Posts:
    326
    Thank you. This is why I randomly read forums. I had not even thought of this. I just used playerprefs without further investigation. It worked for me and I never thought about it again. I will amend my practices to reflect my newfound knowledge.

    From unity manual
    By default Unity writes preferences to disk during OnApplicationQuit(). In cases when the game crashes or otherwise prematuraly exits, you might want to write the PlayerPrefs at sensible 'checkpoints' in your game. This function will write to disk potentially causing a small hiccup, therefore it is not recommended to call during actual gameplay.
     
    angrypenguin likes this.
  10. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    Honestly, it's called PlayerPrefs, I wouldn't expect people to call it during gameplay anyway.

    Given the nature of Unity and the context of many users, I think that's one place where the manual could benefit people by giving a clear reminder that we have a full .NET environment at our disposal, including various file IO and related tools. It would probably save many of the cases I've seen where people struggle to shove inappropriate stuff into PlayerPrefs because they think that's just what Unity uses for saved data in general.
     
    Vryken likes this.