Is there a way in Unity to create a file at runtime and access it in a platform-independent manner? For example, if I want to create a file per user to store arbitrarily complex data (not settings data) and then load that file if it exists at runtime, how would I go about it? I know System.IO can be used but I was hoping for Unity API that might work across platforms and in the web player.
I’m interested too! So far I’ve been using my own functions that assemble strings for PlayerPrefs, but I’d much prefer an XML file or something like that…
System.IO is fine, as well as cross-platform, but you can’t save files in the web player. You can upload them to a server though.
–Eric
System.IO and System.XML are both fine, but System.XML should be used with caution in a web player - it increases the size of the player considerably.
I ended up using:
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
which works great. It won’t take into account the web player but I’ll wrap this code to detect the Platform and do this in the case of all but the web player and figure out something else for the web player specifically.