Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by 017Bluefield · Apr 06, 2017 at 06:39 AM · playerprefsplayer settingsspecificconfusednaming

A distinction of what PlayerPrefs is

From what I understand, a "PlayerPref" is supposed to save data relevant to the player. However, I'm somewhat confused by the name. Is it supposed to save the player's system preferences, or is it used for more than that (e.g. "Player Score")?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Chiroculon · Apr 06, 2017 at 12:16 PM

@017Bluefield The word "Player" here refers to the Unity Player, so in the context of your question, that would be the system preferences.

Comment
Add comment · Show 3 · 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 017Bluefield · Apr 07, 2017 at 12:29 AM 0
Share

Does "system preferences" include things like Player Score? Here's an example from the documentation.

avatar image Chiroculon 017Bluefield · Apr 07, 2017 at 07:25 AM 0
Share

I see what you mean.

I looked around some more in the documentation and found this.

It looks like it's meant to contain anything that you would want to save between sessions. I guess it's meant for browser games; kind of like cookies.

avatar image Inaetaru · Apr 09, 2017 at 06:34 AM 0
Share

You could also look at it different way: the word „player“ here refers to system user. For example on Windows, it's one single user (single user account). On Android (AFAI$$anonymous$$ it's not multi-user environment), it's whole system (for example one physical phone).

To answer whether it include things like Player Score, you should answer first whether you're O$$anonymous$$ that under one Windows user / Android device owner can be only one player. If yes, then PlayerPrefs can include Player Score. If no, then you need your own system for storing player data (which can still use PlayerPrefs with keys like „{player-id}/score“). In that case, „system preferences“ should store things like which player played last.

(And one side note: after a few projects, I don't store single values in PlayerPrefs anymore. Ins$$anonymous$$d, I serialize whole „player data“ to json and then store whole json string to single PlayerPrefs value.)

avatar image
0

Answer by OfficialCoatsee · Apr 09, 2017 at 06:37 AM

I have used Player.prefs to store local user information, so it can be used for that, as well as client settings. Basically anything you want to store and retrieve you can set via Player.prefs.

My Start() method contains a little PlayerPrefs script to assess where exactly the Character is at, but you can use it for whatever you like.

 if (PlayerPrefs.GetString ("character_" + username) != "") {
             woodcutting = PlayerPrefs.GetInt ("woodcutting_level_" + username);
             woodcutting_xp = PlayerPrefs.GetInt ("woodcutting_xp_" + username);
             woodcutting_xp_required = PlayerPrefs.GetInt ("woodcutting_xp_required_" + username);
 
             attack = PlayerPrefs.GetInt ("attack_level_" + username);
             attack_xp = PlayerPrefs.GetInt ("attack_xp_" + username);
             attack_xp_required = PlayerPrefs.GetInt ("attack_xp_required_" + username);
 
             Vector3 loaded_pos = new Vector3(PlayerPrefs.GetFloat ("character_pos_x_" + username), PlayerPrefs.GetFloat ("character_pos_y_" + username), PlayerPrefs.GetFloat ("character_pos_z_" + username));
 
             transform.position = loaded_pos;
 
         }

Of course, there are many different ways of doing this.

PlayerPrefs has many different uses. Depends how creative you are.

It also works across a few platforms I have found. Stores and retrieves information successfully on my mac, pc, and in ios. Not sure about browsers or android.

If you needed to set a variable you'd do something like...

 attack_xp_required = PlayerPrefs.SetInt ("attack_xp_required_" + username, "{VALUE}");
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 Chiroculon · Apr 11, 2017 at 12:45 PM 0
Share

I'm getting the idea that, in the case where you don't need to manage multiple files and the data is small, PlayerPrefs could be a simple way to save and load data.

I'm just not certain that this is its purpose; the documentation says it's for player preferences.

Do keep in $$anonymous$$d that on Windows it is saved in the registry, so I recommend only using it for data specific to that one machine, and only for data applicable to the whole machine.

I would probably never store a player's score or progress in there.

$$anonymous$$aybe it makes more sense on mobile platforms.

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

103 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 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 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 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

Faster Way to Increment PlayerPrefs Int 1 Answer

Playerprefs, i dont know how to use 0 Answers

How do I use PlayerPrefs properly? 1 Answer

how i save and load my coins look the script please 0 Answers

PlayerPrefs Not working. How Can I fix it? 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