I’ve been researching for the past hour and I only find people saying to use Playerprefs or Application.persistentDataPath, which use premade files that cannot change locations and that is not what I am looking for.
I’m looking for a simple way to script: When the function is called, write Variable A to an .INI file, and how to read that Variable back. Quite literally the .INI to state:
“[variables]
variableA = 0”
I keep seeing people talk about encryption and making it hard to mod. Please don’t even comment about that. I’ll completely ignore. This isn’t a multiplayer with rampant cheat. This is just a silly game I’m making that I want it to be easy to modify the save file. I see that as a good feature and I want that to be available.
Actually .NET / C# doesn’t have any classes built in that can handle ini files. When you are on windows the OS provides two methods GetPrivateProfileString / WritePrivateProfileString which allows some basic interactions with ini files. However ini files haven’t really been used for along time, especially as like with CSV files, there’s no proper standard everybody uses. Do values need to be quoted? What about multi-line strings as values? Escape characters? How are numbers formatted? Are line comments allowed? etc.
Here’s a general C# SO question about that. It has many answers and potential solutions as well as an old blog article why ini files are kinda deprecated in windows. Most arguments against ini files are mostly still the same. There are other data formats which have well better standards and provide more flexibility like json.
Though I personally use a lot of classical txt files to store all sorts of information and I usually use a pseudo ini format Though that’s not meant to be readable by a program.
Microsoft actually provides an extension library to read configuration data from ini files with the IniConfigurationProvider class. Though there are many more lightweight solutions out there. As I said there’s no golden standard when it comes to ini files, so whatever solution you may use, be aware of it’s limitations.