How to get/set PlayerPrefs while in editor?

I can’t get/set PlayerPrefs within the editor (no err, just does’t do anything)~ is there something special I need to do?

PlayerPrefs in editor works the same way as in builds. Provide us your code, Unity version and OS.

Strange; it works fine when compiled, though.

  • If I watch the registry while I go through the code in the editor, then refresh the registry entry for my game >> nothing (not even an error).

  • If I compile and do the same thing >> if I press refresh in registry, I see the new stuff and the code does what it’s supposed to.

It’s pretty vanilla:

    public static string LastRoomName
    {
        get
        {
            return PlayerPrefs.GetString("LastRoomName");
        }
        set
        {
            PlayerPrefs.SetString("LastRoomName", value);
        }
    }

5.6.1p1 / Windows 10 (x64)
3083037--232157--upload_2017-5-25_15-52-10.png

I also tried launching as admin, and without admin. Both, no dice.

have tried calling Save() manually?

(works fine in 5.3.7 editor at least…)

1 Like

Whoa, you blew my mind

What the…?? Why would this ever be default? This sounds like something really important to add to the PlayerPrefs doc (@ Unity )

I’m just testing now, but feeling confident!

Edit: nogo on editor while not admin. Gonna try as admin

seems to work in 5.6.1.p1 here (win10) *without save also

Same ver, same OS, and without save … ok something has to be wrong on my end, but I wonder what –

Thanks for tips, mate

This is happening to me right now. Everything I’m passing to PlayerPrefs is valid as I’m checking the values beforehand. I am doing this during a FirebaseUser.UpdateUserProfileAsync()…

print(Utils.LOGGED); // == "LOGGED"
print(Utils.EM); // == 1
PlayerPrefs.SetInt(Utils.LOGGED, Utils.EM);

@MrLucid72 did you figure this out?? I am also trying PlayerPrefs.Save() afterwards with no luck. It never exits PlayerPrefs() as I have tried to print afterwards, but nothing…

I figured this out on my end. I was getting the problem because I was calling SetInt() off of the main thread using Firebase. Thankfully Firebase has a thread safe way to do this via ContinueWithOnMainThread(), if you are not using Firebase, there are other way in which to get in sync with the main thread. Anyhow, hope this helps…