https://github.com/AscheLab/AscheLib.SerializableDictionary
Dictionary that can be edit on Inspector
https://github.com/AscheLab/AscheLib.SerializableDictionary
unity unity-editor
Last synced: about 1 year ago
JSON representation
Dictionary that can be edit on Inspector
- Host: GitHub
- URL: https://github.com/AscheLab/AscheLib.SerializableDictionary
- Owner: AscheLab
- License: mit
- Created: 2020-02-03T13:32:50.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-17T10:37:16.000Z (over 4 years ago)
- Last Synced: 2024-11-10T19:33:33.732Z (over 1 year ago)
- Topics: unity, unity-editor
- Language: C#
- Homepage:
- Size: 2.39 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AscheLib.SerializableDictionary
Created by Syunta Washidu (AscheLab)
## What's SerializableDictionary?
SerializableDictionary is an alternative class to System.Collections.Generic.Dictionary class that can be displayed and edited in Inspector.
## Install
### Using UnityPackageManager
Find the manifest.json file in the Packages folder of your project and edit it to look like this.
```
"scopedRegistries": [
{
"name": "Unofficial Unity Package Manager Registry",
"url": "https://upm-packages.dev",
"scopes": [
"com.aschelab"
]
}
],
"dependencies": {
"com.aschelab.serializabledictionary": "1.4.4",
...
}
```
## Using for SerializableDictionary
```csharp
using System;
using UnityEngine;
using AscheLib.Collections;
```
```csharp
// Define KeyValuePair class that can be displayed in Inspector (key: string, value: int)
[Serializable] public class SerializableKeyValuePair : SerializableKeyValuePairBase { }
// Define Dictionary class that can be displayed in Inspector (key: string, value: int)
[Serializable] public class SerializableDictionary : SerializableDictionaryBase { }
// Use the Dictionary class that can be displayed in the Inspector
public SerializableDictionary _testDictionary;
// It can be used like System.Collections.Generic.Dictionary class
private void Start() {
if(!_testDictionary.ContainsKey("zzz")) {
_testDictionary.Add("zzz", 2525);
}
int zzzValue = _testDictionary["zzz"];
Debug.Log(zzzValue);
}
```
If it is Unity 2020.1 or later, you can also write as follows
```csharp
// How to write Unity 2020.1 and above
public SerializableDictionary _testDictionary;
private void Start() {
if(!_testDictionary.ContainsKey("zzz")) {
_testDictionary.Add("zzz", 2525);
}
int zzzValue = _testDictionary["zzz"];
Debug.Log(zzzValue);
}
```
## Displayed on Inspector

## License
This library is under the MIT License.