(current.gen Markup Language)
A quick way to save data to text files and read it back - not fast, not perfect, but it's simple and does what I want. Slowly adding features.
Built in C# for Unity but can be used anywhere, wiki soon if anyone wants it
Disclaimer: this library is undergoing large changes often and may not be (definitely isn't) ready for production. Use and update with caution. If you're still interested, keep reading.
I wanted a simple node-based system for moving data in and out of text files, so here we are. Let's go through some key points:
- A
Node
is a class that has a name and (optional) value, and can store attributes as a special list (think XML/HTML) - All nodes can have child nodes
- All child nodes are just normal nodes, allowing for unlimited hierarchy levels
- A
CGMLObject
is a class with a single ordinary root node - Nodes can very easily be looped through recursively
A pretty-printed settings file
<Root>
<Audio>
<Volume="0.8" Sound="1" Music="1">/
/
<Display>
<Resolution ResX="1280" ResY="720" Freq="60">/
<VSync="0">/
<Fullscreen="2" Monitor="0">/
/
<Graphics>
<ShadowDistance="200">/
<ShadowQuality="2">/
<TextureQuality="2">/
<AntiAliasing="1">/
<ViewDistance="2">/
/
<Gameplay>
<Difficulty="1" EnableMonsters="true">/
/
<Controls>
<Sensitivity X="0.4" Y="0.4">
<Linked="true">/
/
/
/
- Ease of use
-
- Can convert between text files and class instances with a single function call
-
- Node system is easy to understand, simple to use
- Easily optimized
- Readable when translated to a string
- Node and attribute keys must not include spaces or angle brackets
- Change to dark theme
- Follow 2019.4+ instructions
- Open Package Manager
- Click the
➕▾
button - Click
Add package from git URL...
- Add
https://github.com/Alscenic/cgml.git
- In your project folder, open
Packages/manifest.json
- Add
"com.currentgenstudios.cgml": "https://github.com/Alscenic/cgml.git",
to the dependencies
I highly recommend you use one of these UPM extensions:
- https://github.com/QuantumCalzone/UnityGitPackageUpdater
- Simple
- https://github.com/mob-sakai/UpmGitExtension
- More advanced
- (use 1.3.3 instead of 1.3.4 for Unity 2020.2.X if you experience problems)
- Clone the repository to your project folder and update when necessary
Email me if you have questions, concerns, suggestions, or just want to tell me how much you hate it (https://github.com/Alscenic)
All included code is © Kyle Lamothe 2021