Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ExtremePowers · Dec 06, 2014 at 06:12 PM · playerprefssavequality

Save Quality settings

How to save which quality setting the player has chosen using PlayerPrefs, my idea of this would lead to something like this:

 PlayerPrefs.SetInt("UnityGraphicsQuality", QLevel);

Where QLevel is a number that changes when the player clickes a button, but this seems to get reset everytime the game restarts. NOTE: I have disabled the start up menu, because I wanted it to be in-game only.

So, before restart I run this code: QLevel Starts as 3, then the player changes QLevel to be 5.

 PlayerPrefs.SetInt("UnityGraphicsQuality", QLevel);
 PlayerPrefs.Save();

Then after a restart I run this code:

 var QLevel = PlayerPrefs.GetInt("UnityGraphicsQuality");
 QualitySettings.SetQualityLevel (QLevel, true);

After the restart if I Debug.Log QLevel it is 3, so the value got reset on startup. I have checked in the registry and the value becomes 5 untill I restart the game, then it is back to 3.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Ouss · Dec 06, 2014 at 08:52 PM

You save QLevel in player prefs, but where do you load it so you can get the previous value ? you should have a variable retrieving the value saved in the player prefs: PlayerPrefs.GetInt("UnityGraphicQuality");

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ExtremePowers · Dec 06, 2014 at 11:10 PM 0
Share

That is what i am doing, sorry for not making it clear. The problem is that everytime i launch the game the value is the same Quality number 3 and if i check in the registry it has also been changed to that value.

avatar image
0

Answer by SquigglyFrog · Dec 07, 2014 at 12:26 AM

You might be setting it to some initial value every time you run it, before you load.. You can do something like this:

 if(playerprefs.haskey("UnityGraphicsQuality")
 
 {
 
     qLevel = playerprefs.getint("UnityGraphicsQuality");
 }
 else
 {
     playerprefs.setint("UnityGraphicsQuality", 3);
     qLevel = 3;
 }


This way if it IS set it just reads it in, if its not it sets it..

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ExtremePowers · Dec 07, 2014 at 08:41 AM 0
Share

Okay, 1. I set the value using olayerprefs and when i check in the registry it is changed. 2. I restart the game, and the value gets redet to wha it was before the value was set. 3. when i get the value it is giving me 3 after a restart. All in all, the value gets saves but after a restart is isn't saved.

avatar image
0

Answer by ExtremePowers · Dec 23, 2014 at 10:31 PM

I had to do a workaround, by saving and loading it as something else, so it didn't get reset after the restart.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by saviom80 · Feb 12, 2018 at 12:02 PM

@ExtremePowers can you help me with te code written for setting and saving the quality settings

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

PlayerPrefs Bug 0 Answers

How do I save a three dimensional array? 1 Answer

How to save an Audio Mixer's value wich is adjusted with a Slider? 1 Answer

Save/load playerprefs 2 Answers

Problems with saving/loading score with PlayerPrefs [C#] 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges