ConfigSystem Cs
ConfigSystem Cs
Generic;
using System.IO;
using System.Linq;
using System.Xml;
/*HOW TO USE:
1) change the namespace
2) change the FolderName and the FileName
3) in your awake, call Check("string name") for every boolean you want to use.
- To add a new value to the config, just call Check("thevaluename")
- Alternatively if you want to set it to a specific value, you can use
Set("thevaluename", boolean value);
- Once you have "checked" all of the values you want, call TryWriteConfig();
- There is an example of how to make use of this to create a functional config
below.
*/
namespace YourNamespace
{
public static class Config
{
public const string FolderName = "SaltTestNPC";//this is the name of the
folder, you can have multiple configs in a folder just fine
public const string FileName = "GameData";//this is the file name, change
the file name for each config
public const bool Default = true;//when generating new config values, it'll
set them automatically to this value.
if (xmlDocument.GetElementsByTagName("config")
[0].Attributes[name] != null)
{
add = bool.Parse(xmlDocument.GetElementsByTagName("config")
[0].Attributes[name].Value);
}
if (!SaveConfigNames.Keys.Contains(name))
SaveConfigNames.Add(name, add);
else
SaveConfigNames[name] = add;
}
inStream.Close();
return add;
}