An open API service indexing awesome lists of open source software.

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.

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 :

![image](https://github.com/user-attachments/assets/e21f8b58-6624-4b88-9f17-2cfd9183a4ef)

![image](https://github.com/user-attachments/assets/0c24fe55-6bb6-4418-a07e-0f1f55d6c07d)

# Usage

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

![image](https://github.com/user-attachments/assets/11567ebe-f3f5-4e98-a90b-d5ef9d8b3c96)

``` 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);
```