How to save/load data to/from an external file? (not PlayerPrefs)

I want you to tell me if it is possible to save a variable (let’s say a String “Hello WOrld”) to a .txt file, or any other type of variable, and load it/them to my game.

If it is not difficult post me the code for:

  • Make a GUI with an input field and two button, one for save, one for load.
  • Enter the string to the input field and press save.
  • A file is created containing the data. NOTE: I don’t want PlayerPrefs! I want an individual file, with its own path and extension, shareable.
  • Then press Load and the data is loaded and ready for use.
  • And all that with Javascript!!!

Can it be done with Unity API?
Do I have to use MSDN library? And how can this be done?

tldr: How to save/load from to/from an eternal file data?

This is crusial for my game.
Thank you.

System.IO.File Come up with some kind of format (binary, CSV, whatever) and use functions such as ReadAllText/WriteAllText or similar.

I don’t know javascript, so sorry if this isn’t much help. With c#, it looks like you could use streamreader and streamwriter to access files. You’ll have to add the system.io namespace for them to work.

As for writing that stuff out, that’s a lot of code depending on how you want things to behave when handling files. I am not sure if unity has a built in function, so someone else may be able to help you better with that.