Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/persomatey/unityjsonserializerplugin
A JSON serializer package for Unity which supports reading from and writing to JSON files.
https://github.com/persomatey/unityjsonserializerplugin
unity unity-package unity-packages unity-plugin unity2d unity2d-package unity2d-packages unity2d-plugin unity3d unity3d-package unity3d-packages unity3d-plugin
Last synced: 1 day ago
JSON representation
A JSON serializer package for Unity which supports reading from and writing to JSON files.
- Host: GitHub
- URL: https://github.com/persomatey/unityjsonserializerplugin
- Owner: Persomatey
- Created: 2022-09-05T23:20:57.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T00:02:27.000Z (almost 2 years ago)
- Last Synced: 2024-11-10T13:52:27.455Z (about 1 month ago)
- Topics: unity, unity-package, unity-packages, unity-plugin, unity2d, unity2d-package, unity2d-packages, unity2d-plugin, unity3d, unity3d-package, unity3d-packages, unity3d-plugin
- Language: C#
- Homepage:
- Size: 625 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Unity JSON Serializer Plugin
A JSON serializer plugin for Unity which supports reading from and writing to JSON files.Check out [releases](https://github.com/Persomatey/JSONSerializerPlugin/releases) to download the unity package.
## Tutorial
Tutorial
### Setup
Since everything in this plugin is wrapped in a JSON namespace, you'll need to add it at the top of your script.
```
using JSON;
```Because .json files are read as TextAssets in Unity, you'll need a reference to the TextAsset in your script like so:
```
[SerializeField] TextAsset file;
public TextAsset file;
```
---
### Creating a new JSON object from a file
Call the constructor, using the TextAsset you want read in the parameters.
```
JSON myJSON = new JSON(file);
```
There is also a constructor for if you don't have a parameter.
```
JSON myJSON = new JSON();
```
---
### Serializing JSON object to a file
You can serialize the JSON object to the provided TextAsset file.
```
writeJSON.WriteToFile();
```
If no parameter was provided when object was created, you'll need to include the TextAsset in the parameters of `WriteToFile()`
```
writeJSON.WriteToFile(file);
```
---
### Reading, writing, and removing JSON variables
To read a specific variable (`GetBool`, `GetInt`, `GetFloat`, `GetString`):
```
myJSON.GetString("myStr");
```
To change a specific variable (`SetBool`, `SetInt`, `SetFloat`, `SetString`):
```
myJSON.SetInt("myInt", 246);
```
To add a variable to the JSON (`AddBool`, `AddInt`, `AddFloat`, `AddString`):
```
myJSON.AddFloat("myFloat", 24.68);
```
To remove a variable from the JSON (`RemoveBool`, `RemoveInt`, `RemoveFloat`, `RemoveString`)
```
myJSON.RemoveBool("myBool");
```
---
## Details
Specs
Unity 2020.3.32f1
- Windows: https://download.unity3d.com/download_unity/12f8b0834f07/UnityDownloadAssistant-2020.3.32f1.exe
- Mac: https://download.unity3d.com/download_unity/12f8b0834f07/UnityDownloadAssistant-2020.3.32f1.dmg
- Unity HUB: unityhub://2020.3.32f1/12f8b0834f07SLN solution in Visual Studio Community 2019 Preview
https://visualstudio.microsoft.com/vs/community/