• 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 Adam 3 · Jul 01, 2011 at 04:23 PM · playerprefssaveclear

PlayerPrefs wont save info

Hey guys I'm currently working on a decent sized game with my fellow co-worker (In a small independant game companay). For now we are using PlayerPrefs rather then a database, as I usually do. But Just about an hour ago, no more information will be saved. I can still load all the old info saved on each playerpref, but no longer assign new data to them. I've searched around for something similar for anyone and I couldn't find anything. I thought if I cleared my PlayerPrefs folder it may work, but I cant find the folder and the small editor script I made wont work.

class ClearMyPrefs extends EditorWindow { private var Sceen:int=1;

 @MenuItem ("Windows/ClearPrefs")
 static function Init () {
     var window = EditorWindow.GetWindow(ClearMyPrefs);
 }

 function OnGUI () {
     if(Sceen==1){
         GUILayout.Space(20);
         if(GUILayout.Button("Delete All Prefs")){
             Sceen=2;
         }
     } else {
         GUILayout.Space(20);
         GUILayout.Label("Are you sure?");
         GUILayout.BeginHorizontal();
         if(GUILayout.Button("Yes")){
             PlayerPrefs.DeleteAll();
             Sceen=1;
         } 
         if(GUILayout.Button("No")){
             Sceen=1;
         }
         GUILayout.EndHorizontal();
     }
 }

}

If someone could help me figure out why they wont save and why I cant clear my folder it'd be much appreciated, thank you.

Extra Detail: I have my computer split into 2 drive, C:\ and E:\, I have Unity saved in the E:\ incase C:\ crashes.

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 aldonaletto · Jul 01, 2011 at 04:33 PM 0
Share

There is a 1 megabyte size limit for web player PlayerPrefs, but it seems standalone versions don't impose any limit.

avatar image Adam 3 · Jul 01, 2011 at 04:49 PM 0
Share

This makes sense then, the hole project is Web based, I guess we'll have to switch to the Database sooner then I hoped, but I'd still like help with clearing the PlayerPrefs if anyone can.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jul 01, 2011 at 05:46 PM

You have to keep in mind that the PlayerPrefs works totally different depending on what platform you run your game.

Read the docs on PlayerPrefs carefully. If you run inside the editor the data is stored in the registry. Running the same game as standalone / in the editor / in the webplayer will result in different PlayerPrefs storage places. If you want to clear the prefs you need a script at runtime that you can execute even in the webplayer.

Comment
Add comment · Show 2 · 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 Designosaurus · Apr 17, 2016 at 11:14 PM 0
Share

Link to "docs on PlayerPrefs" is broken.

avatar image Eno-Khaon Designosaurus · Apr 18, 2016 at 12:43 AM 0
Share

Thanks for the catch -- updated the link.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

How do I save a custom class of variables to playerprefs? 2 Answers

How to save dictionary keycode values to PlayerPrefs with C# 2 Answers

Save score in Unity 1 Answer

Checkpoint with PlayerPrefs 0 Answers

Need help with PlayerPrefs 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges