Unity "player preferences" file format and contents - unity3d

Upon quitting my application, I use PlayerPrefs.Save() to save the player preferences.
I understand this function writes all the modified preferences to disk.
So, I clicked on Start, typed regedit and opened it, went into HKEY_CURRENT_USER and then Software and then I selected Unity.
So, now I can see the file (is this actually a file?) but I cannot figure out how to open it or see the contents...
Neither double-clicking on it works nor right-clicking on it brings up any menu with options.
How do I access the contents, or perhaps clear/flush it after a while?

You find the PlayerPrefs under:
HKEY_CURRENT_USER/SOFTWARE/[NAME OF THE COMPANY YOU SPECIFIED IN PLAYESETTINGS]/[PRODUCTNAME YOU SPECIFIED IN PLAYERSETTINGS]

If you had checked unity's documentation it is very well explained for each platform here

The exact storage of PlayerPrefs depends on the platform. For Windows it is stored in the registry, as you have seen.
This is not an isolated file for your Unity game. As such, there is nothing really to open. You could edit the registry if you wanted to, but that's not really the appropriate way. Just keep using it via the provided PlayerPrefs API.
If you want to clear your playerprefs, you can call PlayerPrefs.DeleteAll(). This will clear all playerprefs data and would allow you to "simulate" a new user starting from scratch for example.

For Win32 and Win64 builds it is in a Registry file editable from the registry.
In OS X builds it is in a plist file in ~/Library/Preferences These are in plist compliant format and can be edited in the standard OS X plist editor, or a text editor if you follow proper syntax.
In Windows Store builds it is in %userprofile%\AppData\Local\Packages[ProductPackageId]>\LocalState\playerprefs.dat (I don't know the format of this.)
Windows Phone builds store it in the application's local folder, again no documentation on format.
Android and Linux are in xml format, editable with a standard text editor.
The Android config files are package's shared prefs directory and the Linux config files are under ~/.config/.unity3d

Related

How to open file with a Flutter app on MacOS/Windows?

I have an app that should open certain file types. From the app itself, it's quite straightforward with file_picker plugin. But how to open a file trough the file manager? In other words, trough the "Open with" context menu.
I tried checking the arguments passed to main, but they are always empty. Registering a universal link wouldn't make much sense either since I only need to pass the file - nothing more.
The Mac problem is related to the fact that the development sandboxes your program. I encountered a similar problem and tried to summarize it on
Entitlement issue
you can find the setting in the entitlements (debug and release) at
<key>com.apple.security.app-sandbox</key><true/>
if (await canLaunch("file://..path...xlsx")) {
await launch("file://..path...xlsx");
} else {
print("cannot launch url ]:");
}
this simple snippet basically works both on windows and mac os! If you can deal with path with classic path_provider, you'd be able to use the same feature on web, ios, android also. In my test, web downloaded the file when i typed and entered the file:// url.
So, i guess the uri scheme is the one who does these tricks. I tried a few types of files and as i commented, excel works just fine and the finder(or file explorer) also work. In my test, pptx even worked with the file url. Yes, it opens the native app. I couldn't have found out "open with.." option, but it meant that it automatically open xlsx file in excel(ie. ATM i don't have any option to launch "open with.." pop-up tho).
Similarly, i could have even found that instagram:// also works with url launcher. One thing unexpectedly tough was to set a proper path on mac os desktop. Since the app is being debugged somewhere assigned previously by Mr. Apple, simply calling methods from path_provider returned a path far away from desktop path, the home screen, since the app is running on somewhere else(like /Users/${MacOsUser}/Library/Containers/${fullPackagePath}/Data/Documents for mac os, which would be different in the distribution stage).
Hope this would help. FYI, i couldn't launch battle.net and league of legends with this method, which don't show their extensions in the file explorer ]: Have a wonderful day [:

How to force reload preference plist for an app in OS X?

My swift program periodically updates the com.google.Chrome.plist file stored in /Library/Preferences.
During the initial executions, it just needs a restart of Chrome browser for the policies to take effect. But now I need to restart the system to make the policies to take effect. How do I get it to update without restarting the Mac?
And also the Reload policies button in chrome://policy won't do the trick. (I wonder what's its purpose?)
And also, please explain the difference between placing the plist file in /Library/Preferences and in /Library/Managed Preferences
Or is there any command for OS X, like gpupdate /force (for windows) as they said here.
I also recently found that this problem persists for other apps too ( I tried editing the plist file of Safari from ~/Library/Preferences/com.apple.Safari.plist and it requires a system reboot to take effect )
I'm stuck here for long. A nudge in the possible direction would do too!
Thank you!
The reason is, from Mac OS Mavericks, apple started to cache plist files, which results in replacing a plist file manually has no effect until the cache is reloaded automatically. If you open the application which uses this plist file to early, it overwrites your copied file with the old/cached one.
To reload the preference file manually, use defaults read <filename>.plist to read the new plist values.
Source: nethack
Now, I just use a sh script to call the defaults after executing my program.

How does my computer know to assign a certain image to .doc files?

Is the icon file for .doc and .docx built-in to Windows, Mac, and Linux because it's so common? Or would the OS only know to associate that extension with the icon image IF Microsoft word/office was installed, which gave the image file to the OS and instructed it to make the association?
I didn't know how to search for this. I also didn't know whether to ask on Superuser, SO, or Programmers.SE.
For windows, when an application is installed, it registers with the OS what file extension it has for the files. So when you install Office or MS Word, it will tell the OS that it's files can be .doc or .docx and what icon to use for those. Then when any files that have that extension are shown, it will open up in that program. It stores the info in the registry.
If you try to open a .docx file that is not registered, meaning Office not installed, it will ask you to choose a program to launch it with, because it doesn't recognize the file.
You can also manually associate files as well to a specific program if it is not registered.
Most of the time, the associations are done when the said application is installed.
Some operating systems such as Mac and Linux can associate files with their mime type e.g. text/plain. That way it would know to use a text editor to open the file.
You can read a little more detail here about file associations.
http://en.wikipedia.org/wiki/File_association
In windows vista/7, go to your control panel, and search for 'assoc'. Under folder options it has a option labeled 'change the file type associated with a file extension'. This will give you a list of all of the files extension (what comes after the '.') and what program/icon they use.
Most programs create these extensions when they are installed. Some very common formats, like .html, will have association made on any modern system.
Files also get associated when you tell the system which program to use to open a type of file. The icon that type of file uses is usually just the icon associated with the program in that case.
Hope that answers your question.

Creating a file type with new icon

I have a text based file i have given an extension named .val i have also changed its icon by selecting Computer>Open tools>Open folder options>
however though this changes the icon for the extension it only changes it on my computer, I would like to know how I can do this for all machines. even if that means building somthing that needs to be installed, which is fine with me
I wrote a little program awhile ago. The windows registry thing is a mess. Save yourself a lot of time and use this installer package - it has a wizard that will create an install script for you. Navigate to your program, icon, etc. Pretty easy.
http://hmne.sourceforge.net/
As I recall, in windows icons are set based on what program is opening it, so indirectly the file type. So first you have to create reg entries for your application on your computer. Then you have to associate that file type with your extension. And then the extension gets the icon from your app settings. This of course is different in WinXP vs. Win7. Thus why I think you should avoid a lot of headache and use an installer.
[HKEY_CLASSES_ROOT\Your App\DefaultIcon]

How to convert an Info.plist file from mac os project to iphone project?

I am developing an app for the iPhone OS devices, and am using a third-party engine which is not well documented but I've made great progress with it anyway.
The problem:
The engine's developer strongly urges extending from the existing template projects bundled with the engine, but the engine's Info.plist files are Mac OSX project Info.plist files.
This is an iPhone engine, and so I cannot understand why the Info.plist file is structured to take keys for Mac OS apps, but that's how it is.
I did a FileMerge comparison to ensure there was nothing within the file itself that defined its use for one OS or the other, so I guess it's defined somewhere in the project settings.
Edit -
Opening the plist file in Xcode or Property List Editor and then trying to add a key such as "Icon already includes gloss and bevel effects" will not work in this iPhone project because it is not in the list. However, "Cocoa Java Application" and others are available!
The meta information for iPhone/iPad projects is stored in /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneInfoPlistStructDefs.xcodeplugin, assuming you took the installation defaults -- ymmv. I successfully merged some information into there from /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Plug-ins/InfoPlistStructDefs.xcodeplugin. For some reason, the iPhone plugin didn't have all the human-readable names in the "Documents" category.
Here's some information I collected from
iPhone dev center within the About Information Property List Files chapter:
Important: The property list editor in
Xcode displays human-readable strings
(instead of the actual key name) for
many keys by default. To display the
actual key names as they appear in the
Info.plist file, Control-click any of
the keys in the editor window and
enable the Show Raw Keys/Values item
in the contextual menu. When typing
key names yourself, you should always
type the actual key name.
This is useful for future reference, the recommended behaviour for updating the Information Plist files...
Additionally, my research has led me to believe the pre-loaded human-readable key names CANNOT be recreated unless someone creates a new project. It is stored somewhere in the meta information of the project itself and the Property List Editor can interpret that, not to mention Xcode itself. So, until someone decides to interpret that meta info, it's just a matter of using the recommended approach as mentioned above.