https://github.com/shaun-fong/kv-reader
Key-Value file reader for unity.
https://github.com/shaun-fong/kv-reader
data-table editor game-development k-value unity unity3d unity3d-plugin
Last synced: 4 months ago
JSON representation
Key-Value file reader for unity.
- Host: GitHub
- URL: https://github.com/shaun-fong/kv-reader
- Owner: Shaun-Fong
- Created: 2024-11-09T06:55:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-11T12:44:35.000Z (over 1 year ago)
- Last Synced: 2025-04-09T06:34:48.573Z (about 1 year ago)
- Topics: data-table, editor, game-development, k-value, unity, unity3d, unity3d-plugin
- Language: C#
- Homepage:
- Size: 73.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
KV-Reader
Key-Value file reader.
This is a simple key-value structure file parser, which can be used for various purposes, such as configuration files, do whatever you want.
# Install
For Unity, download package from [here](https://github.com/Shaun-Fong/KV-Reader/releases/latest/download/com.shaunfong.kvreader.unitypackage).
For Dll, download from [here](https://github.com/Shaun-Fong/KV-Reader/releases/latest/download/ShaunFong.KVReader.dll).
# K-V File
The typical K-V file is as follows:
```
// Comment line1
// Comment line2
// Comment line3
KEY VALUE1
KEY1 VALUE2
```
This tiny library can parse almost any file :


# Usage
Open `KV Reader` Tool by clicking `Tools/KV Reader`

``` C#
// Reader Parse
Reader reader = new Reader();
// Parse
reader.ParseFromString(File.text);
// Print
Console.WriteLine(reader["KEY"][0]);
```
``` C#
string test = @"
// Comment
KEY1 VALUE1
KEY2 VALUE2
";
// Parse
var data = Reader.ParseDocumentFromString(test, out List headComments);
// Read
Console.WriteLine(data[1].Key + " " + data[1].Value);
// Change Value
data[1].Key = "KEY_CHANGE";
data[1].Value = "VALUE_CHANGE";
// Format
var result = Reader.FormatDocumentToString(data, headComments);
// Print Result
Console.WriteLine(result);
```