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
1
Question by Waz · Nov 06, 2011 at 12:48 AM · webplayerplayerprefsloadmultiple

PlayerPrefs: force *Load*?

Can I force Unity to reload PlayerPrefs from disk?

It is possible to force PlayerPrefs to be saved using PlayerPrefs.Save(), however, there is no equivalent for loading.

I have a WebPlayer game, and at certain times I want to synchronize between multiple instances in different windows - eg. if the player saves his game in one WebPlayer instance, I call PlayerPrefs.Save() to ensure it's on disk, but when in another WebPlayer instance he needs to Load, I need to ensure that PlayerPrefs are reloaded.

From testing, the WebPlayer ignores changes to the underlying file.

Comment
Add comment · Show 2
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 Diet-Chugg · Nov 06, 2011 at 12:54 AM 0
Share

You could try get all the variables individually and see if that works. However, there is no force Load that I can find.

avatar image Waz · Nov 06, 2011 at 01:45 AM 0
Share

I'm not sure what you mean by getting all the variables individually. When I retrieve values (individually - is there any other way?), I do not get ones recently written to disk with Save() in another WebPlayer.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Feb 06, 2012 at 11:19 PM

Well, i don't think that's possible. Interprocess communication was never the aim of PlayerPrefs. Sure, it would be nice to use it that way, but i guess you have to communicate over your hosting server. I don't see much alternatives.

Well, when hosted on the same domain (which would also be necessary for PlayerPrefs since it depends on the URL) you could try to go through the browsers Javascript with ExternalEval, find the other instance and use SendMessage of the UnityPlayer-plugin.

It might get a bit tricky to locate the other instance(s), but when you created the webpage you can always name the window / tab in a way it can be found by others.

Comment
Add comment · Show 4 · 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 Waz · Feb 06, 2012 at 11:29 PM 0
Share

At one time it was "never the aim" of Unity to work on Windows, and only $$anonymous$$acOSX was supported. I'll hope for Unity to add PlayerPrefs.Load() rather than make excuses for them.

avatar image Bunny83 · Feb 06, 2012 at 11:49 PM 1
Share

;) absolutely agree on that. Save() has also been added afterwards. But i guess even when you file a feature request it's really one of the lowest priority requests (i only count the serious ones) since there are really just a few people that need this feature.

avatar image Bunny83 · Feb 07, 2012 at 12:08 AM 0
Share

$$anonymous$$aybe reloading of the .unity3d file will also reload the playerprefs, but, of course, that would restart your game / app.

Just use WWW.LoadUnityWeb

avatar image Waz · Feb 07, 2012 at 12:13 AM 0
Share

That's one of the problems with democratic feature requests, it can obfuscate trivial requests like this. But yes, if they spent all day on trivial stuff, $$anonymous$$acOSX developers would have PlayerPrefs.Load already ;-)

avatar image
-1

Answer by HolBol · Feb 06, 2012 at 05:27 PM

I've had it update while the game is playing before, with no problem. Are you using PlayerPrefs.Load()? It might be what you are looking for. If not, then.. I'm not sure how to help you!

Comment
Add comment · Show 7 · 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 Waz · Feb 06, 2012 at 10:44 PM 0
Share

There is no "PlayerPrefs.Load()", only Save(), which is the problem.

avatar image HolBol · Feb 06, 2012 at 11:04 PM 0
Share

Ahh. Can't you just use the GetInt, GetString, and GetFloat functions?

avatar image Waz · Feb 06, 2012 at 11:07 PM 0
Share

Would using SetInt, SetString, and SetFloat replace the Save function? No. The point is, if prefs are changed in another concurrent webplayer instance, they are not visible in the earlier-started instance.

avatar image HolBol · Feb 06, 2012 at 11:30 PM 0
Share

Please, calm it a little. What I'd do is put in a feature request. They may have intentionally left it out for security reasons, however.

avatar image Bunny83 · Feb 06, 2012 at 11:53 PM 0
Share

@Fishman92: That doesn't make much sense. The OP already said that "there is no equivalent for loading", so why do you suggest to use a function that doesn't exist? Also i can't even imagine any case where the reloading of the playerprefs could be a security issue.

Show more comments

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

WebPlayer save scores of different players 1 Answer

Guide in ArrayPrefs or PlayerPrefx? 1 Answer

Save and share from Web Player 1 Answer

How do you load a single sprite, from a multiple sprite sheet, in a data base? 0 Answers

Playerprefs issue in WebGL 0 Answers


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