Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SolAnna7/PiscesConfigLoader
A (YAML) configuration loader and reader tool for Unity
https://github.com/SolAnna7/PiscesConfigLoader
config configuration immutable unity yaml yaml-configuration
Last synced: about 2 months ago
JSON representation
A (YAML) configuration loader and reader tool for Unity
- Host: GitHub
- URL: https://github.com/SolAnna7/PiscesConfigLoader
- Owner: SolAnna7
- License: mit
- Created: 2020-06-20T20:55:49.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-04T17:30:11.000Z (almost 4 years ago)
- Last Synced: 2024-08-02T05:14:01.684Z (5 months ago)
- Topics: config, configuration, immutable, unity, yaml, yaml-configuration
- Language: C#
- Homepage:
- Size: 47.9 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PiscesConfigLoader 0.9
A configuration loader and reader tool for Unity
## Features
* 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## System Requirements
Unity 2018.4 or later
## Dependencies
* [YamlDotNet](https://github.com/aaubry/YamlDotNet) (forked git submodule)
* [ExpressionParser](https://wiki.unity3d.com/index.php/ExpressionParser) (from unity wiki)## Installation
* 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~~
## Usage
##### Build the config tree
* Parsing resource files
```c#
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```c#
var configRoot =
new ConfigBuilder()
.ParseString(@"
aaa:
bbb: 123
ccc: ddd", new ConfigBuilder.YamlTextConfigParser())
.Build();
```* Merge dictionaries
```c#
var configRoot =
new ConfigBuilder()
.MergeDictionary(
new Dictionary
{
{
"aaa", new Dictionary
{
{"bbb", 999},
}
}
}
).Build();
```* Currently contains only a YAML parser but can be extended
```c#
private class TestConfigParser : ConfigBuilder.ITextConfigParser
{
public Dictionary ParseText(string text)
{
if (text == "please!")
return new Dictionary
{
{
"yesssss", "^_^"
}
};return new Dictionary
{
{"nope", "sorry"}
};
}
}...
new ConfigBuilder()
.ParseString("please!", new TestConfigParser())
.Build();
```## Planned features
* Parse from JSON
* Parse from XML
* Load to and save from binary files### 1.0
No features are planned specifically for 1.0, but it wont be released until further testing and real life usage