reading in seperate data values via a text file

Hi,

I wanted to create a short readable text file (*.txt ) for my game which a person could simply edit for settings such as resolution, key-bindings etc ( I’m not using the usual graphics selector on start-up )

I suppose a ( ‘new line’ - /n ) within said text file would be enough to work with as separate data variables for my game to use ?

please advise.

You’re welcome to engineer your own text or “ini” file format.

That’s a LOT of really unpleasant string-fiddling work.

Personally I’d just make the config file a JSON file and be done with it.

Problems with Unity “tiny lite” built-in JSON:

In general I highly suggest staying away from Unity’s JSON “tiny lite” package. It’s really not very capable at all and will silently fail on very common data structures, such as Dictionaries and Hashes and ALL properties.

Instead grab Newtonsoft JSON .NET off the asset store for free, or else install it from the Unity Package Manager (Window → Package Manager).

Also, always be sure to leverage sites like:

https://csharp2json.io

1 Like