A configuration loader and reader tool for Unity
- Parse YAML files to object structure
- Traverse the data tree
- Immutable structure
- Query simple and complex data types
- Mathematical expressions
- Number ranges
- Lists
- Sub config trees
- Merge trees
Unity 2018.4 or later
- YamlDotNet (forked git submodule)
- ExpressionParser (from unity wiki)
- Clone into the Assets folder of your Unity project
git clone [email protected]:SolAnna7/PiscesConfigLoader.git
cd PiscesConfigLoader/
git submodule update --init --recursive
Download from Unity Asset Store
- Parsing resource files
new ConfigBuilder()
// TestYamlFiles is a Resources folder with YAML files in it
.ParseTextResourceFiles("TestYamlFiles", new ConfigBuilder.YamlTextConfigParser())
.Build();
new ConfigBuilder()
// TestYamlFiles/TestYaml1 Resources YAML file
.ParseTextResourceFiles("TestYamlFiles/TestYaml1", new ConfigBuilder.YamlTextConfigParser())
.Build();
- Parsing strings
var configRoot =
new ConfigBuilder()
.ParseString(@"
aaa:
bbb: 123
ccc: ddd", new ConfigBuilder.YamlTextConfigParser())
.Build();
- Merge dictionaries
var configRoot =
new ConfigBuilder()
.MergeDictionary(
new Dictionary<object, object>
{
{
"aaa", new Dictionary<object, object>
{
{"bbb", 999},
}
}
}
).Build();
- Currently contains only a YAML parser but can be extended
private class TestConfigParser : ConfigBuilder.ITextConfigParser
{
public Dictionary<object, object> ParseText(string text)
{
if (text == "please!")
return new Dictionary<object, object>
{
{
"yesssss", "^_^"
}
};
return new Dictionary<object, object>
{
{"nope", "sorry"}
};
}
}
...
new ConfigBuilder()
.ParseString("please!", new TestConfigParser())
.Build();
- Parse from JSON
- Parse from XML
- Load to and save from binary files
No features are planned specifically for 1.0, but it wont be released until further testing and real life usage