Windows Game Save

Does anyone know whether Unity (through Mono?) provides access to the Windows registry?

I am looking for a place to save game data, without forcing the user to go through a file chooser. On the Mac I can drop files somewhere under $HOME/Library/, and on Windows I would store the game state in the registry. (Incidentally, how do I learn the location of $HOME from within Unity?)

Assuming the registry cannot be accessed from Unity, does anyone know of any pseudo-standard game save locations under Windows? (If “My Documents,” then how would Unity find that folders absolute file path?)

You can always just write a C++ plugin.
If you have a C++ compiler on windows already it is pretty easy to create those plugins.

Is there is a solution that doesn’t require a C++ plugin? Because that seems like you are just dodging around the question, telling someone how easy they could do it with a Pro-only feature, which is kinda rude.

The question is about windows deployment, so one can safely assume to have the Pro version.
As far as i can see you can only write to the registry from C# directly using p-invoke which is probably harder than writing a c plugin.
You could of course just put a huge string into the registry using PlayerPrefs.

To get to the user home directory on mac os x:

print("/Users/" + System.Environment.GetEnvironmentVariable("USER"));

… or even better:

print(System.Environment.GetEnvironmentVariable("HOME"));

The home directory is not nessesarily always in /Users/$USER, but that is the system default and most people (i.e. 99.99% of all users) will keep it that way. (An example of users with home in a different place are network users.)

And here’s what you’d do on windows:

print(System.Environment.GetEnvironmentVariable("USERPROFILE"));

… and there is also the APPDATA environment varble on windows.

print(System.Environment.GetEnvironmentVariable("APPDATA"));

More windows environment variables: http://kennethhunt.com/archives/000933.html

Why not just use PlayerPrefs (assuming the functionality you need is enough)? On windows, they are stored in registry (based on your company/product name in player settings).

All good suggestions – thanks! :slight_smile: