Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

5.5 PlayerPrefs moved?

Discussion in 'Editor & General Support' started by mantekkerz, Dec 11, 2016.

  1. mantekkerz

    mantekkerz

    Joined:
    Dec 24, 2013
    Posts:
    111
    Hi all,

    Upgraded a project to 5.5 (don't worry it's backed up!) and straight away I'm into a weird little problem. My project can't find existing reg keys that have been set by older version of Unity's PlayerPrefs. I set up a quick script to recreate the things it couldn't find and things are working now.

    But the keys that have been created/modified are not in the expected place. For example, I can see my old keys, values of which have been changed by my 'quick fix' script (according to Unity when the project runs, but not according to regedit). So in fact, they haven't been modified, but new ones have been created elsewhere. But I can't find them!

    Quick check of 5.5 docs says keys should be in the expected place - HKCU\Software\[company name]\[product name] - But I have used exactly the same key names in my fix script, and I can see in the reg editor that the values have not changed- yet my project when it's running is picking up these new values from somewhere!

    TL;DR PlayerPrefs are freaking me out because I'm not seeing keys appear where expected but Unity is finding them from somewhere, but I don't where. Anyone else had this weird behavior?

    Matt
     
    Ony likes this.
  2. PoppinFresh

    PoppinFresh

    Joined:
    Jun 10, 2014
    Posts:
    5
    For some reason, Unity seems to now be saving the PlayerPrefs under HKCU\Software\Unity\UnityEditor\[company name]\[product name]. On Android, it still found my old save file with no problems, so I'm guessing it was just moved for Windows or maybe this is a bug since the Unity scripting documentation hasn't been updated.
     
    mantekkerz likes this.
  3. mantekkerz

    mantekkerz

    Joined:
    Dec 24, 2013
    Posts:
    111
    Bingo @PoppinFresh! They have moved then. Thought I was losing it :confused:
     
  4. Remster

    Remster

    Joined:
    Feb 18, 2015
    Posts:
    6
    Indeed this is very confusing, because the documentation needs to be updated because it wrongly states:
    https://docs.unity3d.com/550/Documentation/ScriptReference/PlayerPrefs.html
    "On Windows, PlayerPrefs are stored in the registry under HKCU\Software\[company name]\[product name] key, where company and product names are the names set up in Project Settings."
    ..for both "in Editor" and "Standalone".

    I used export/tweak in notepad/import in Regedit to copy back my keys into this new path..
     
  5. SaraCecilia

    SaraCecilia

    Joined:
    Jul 9, 2014
    Posts:
    675
    Ah, thanks for the heads up! Have pinged the Docs team.
     
  6. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,973
    Wait, I just updated to 5.5 and having the same problem, but... Are you saying that when I run the game in the Editor, my prefs will be stored in the HKCU\Software\Unity\UnityEditor\[company name]\[product name] path but when I run it standalone they'll be stored in the regular HKCU\Software\[company name]\[product name path? Why make that change?

    My installers write registry entries as part of the install, at that regular path. When I run my game in the Editor, I don't want to have to create a separate installer with all new paths in it just so I can do my testing. That's annoying as hell and just slows things down. I want to be able to test my game while developing and have it read from where the actual game will read from. And yes, I know I can copy the key from one place to another in the registry, and that's what I ended up doing, but that doesn't address the real issue.

    PLEASE stop messing with the registry paths, unless absolutely necessary to solve some game breaking issue. This is the second time in a few months that the registry paths have been messed up. Please stop.
     
    Last edited: Jan 25, 2017