In other words, if the machine performing the save loses power, is turned off, or something else horrible happens while trying to save, will the PlayerPrefs data become corrupt, or will the system be smart enough to know that the operation failed and revert?
I’m storing some user data in PlayerPrefs that I don’t want to ever get corrupted. Are there any assurances of this?
How important is the data. PlayerPrefs itself can get wiped or corrupted in obscure cases (at least a few bug reports about this), and implementation varies heavily from platform to platform. I can’t recall every reading anything guaranteeing atomic writes, and I’m pretty certain they don’t have anything like an transaction/redo log.
If you are talking about something seriously important like a key that provides access to a digital wallet then PlayerPrefs is not the right choice.
Thanks for the replies. @angrypenguin I wasn’t able to get file I/0 working for mobile due permission issues on IOS. I am building a type of text editor, and wanted to cache the text data somewhere that works on both mobile & desktop.
I think instead I’m going to look into other technologies like ReactJS (and its mobile & desktop exports), because I think the foundation is better for my use case (I have since discovered that Text Mesh Pro has some serious limitations on its input fields). Thanks for helping me explore this option and confirming PlayerPrefs isn’t meant for my use case.
From memory, file IO on iOS works just fine in Mono as long as you stick to the directories your app is allowed to touch. Unity can tell you where that is on both PC and mobile, so as long as you path relative to that you should be fine.