- Home /
Is there a simple way to delete all your playerprefs in the editor and webplayer?
Hej,
I am making a main menu for a game I don't have but just making it and now working on the settings page. Here you must change settings and apply them so you save them in your PlayerPrefs. So when you start up the next time you can use the same settings.
When I changed a lot of code in my scripts I want to see how it works from first startup so I have to delete all my PlayerPrefs but how can i do this fast? because now I am doing them 1 by 1 with this for example :
PlayerPrefs.DeleteKey("Resolution"); PlayerPrefs.DeleteKey("Shadows"); and so on....
I am getting alot of variables to save now and going to be a huge job so i found this :
PlayerPrefs.DeleteAll and EditorPrefs.DeleteAll
but what is the difference is it save to use? I don't want to lose everything i made....
does editorpreference's delete just my preference's in unity -> edit -> preference's or something else?
and does PlayerPrefs.DeleteAll delete's just my PlayerPrefs or has it side effect? I hope i can use this because it saves me alot of time... I think its obvious that is save to use but i want to be sure because in other programs i thought i knew it but when I did it my project was corrupted....
I hope i can ask this kind of stuff and don't violate any rules.
Thanks in advance,
Lemon,
EDIT : and if DeleteAll is just deleting. does it affect only for the project or game you are using/playing at that moment or for all games and projects you have?
Answer by Antony-Blackett · May 15, 2011 at 01:23 AM
PlayerPrefs.DeleteAll() is definitely safe. In fact I use it daily to test if a new player to the game can unlock everything starting from scratch.
I'm unsure what EditorPrefs.DeleteAll() does though.. The docs don't seem to explain very much http://unity3d.com/support/documentation/ScriptReference/EditorPrefs.DeleteAll.html My assumption is that EditorPrefs is meant to be used specifically for tools and editing. Meaning that nothing in your game code should rely on EditorPrefs settings. The player in a final build will not have access to this class because it is contained within UnityEditor which is not compiled into a build.
ok thanks for your clear answer :) going to use it now then ins$$anonymous$$d of delete$$anonymous$$ey just wanted to be sure :)
you are right the editor code does not get put in the binary output.
Answer by CrandellWS · Mar 31, 2019 at 08:40 PM
Quick Delete PlayerPrefs with Menu Button – Unity
code explanation:
using UnityEngine;
using UnityEditor;
public class DeletePlayerPrefsScript : EditorWindow
{
[MenuItem("Window/Delete PlayerPrefs (All)")]
static void DeleteAllPlayerPrefs()
{
PlayerPrefs.DeleteAll();
}
}
use the menu:
Your answer
Follow this Question
Related Questions
Dynamically building a PlayerPrefs key 4 Answers
DeleteAll not working on android? 0 Answers
DeleteAll not working on android? 0 Answers
PlayerPrefs.DeleteAll not working 1 Answer
PlayerPrefs file wrong stored location 0 Answers