https://github.com/mrrobinofficial/unity-parser
A friendly parsing system for Unity. This system supports a wide range of data types, and offers try-parse methods.
https://github.com/mrrobinofficial/unity-parser
ncalc parse parser unity unity3d
Last synced: 3 months ago
JSON representation
A friendly parsing system for Unity. This system supports a wide range of data types, and offers try-parse methods.
- Host: GitHub
- URL: https://github.com/mrrobinofficial/unity-parser
- Owner: MrRobinOfficial
- License: mit
- Created: 2021-11-22T09:58:40.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-03T12:11:53.000Z (almost 3 years ago)
- Last Synced: 2025-10-07T15:08:43.952Z (3 months ago)
- Topics: ncalc, parse, parser, unity, unity3d
- Language: C#
- Homepage:
- Size: 2.08 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Parser [Unity Engine]
*Parsing system for Unity that helps developers easily convert strings into various data types within the engine. This system supports a wide range of data types, and offers try-parse methods to avoid allocating extra memory when parsing invalid strings.*
This parsing system was built using [NCalc](https://github.com/ncalc/ncalc).
[](https://github.com/mrrobinofficial/unity-parser/blob/HEAD/LICENSE.txt)

## Introduction
Parser is a helping system for folks who wants to parser string values into object values.
**NOTE:** This system will try to parse string value as user input into object value.
For an example:
```c#
string input = "on"; // True
```
```c#
string input = "off"; // False
```
I do **NOT** recommend using this parsing system for serializing data. Instead, I highly recommend checking out my other project on [uJSON](https://github.com/MrRobinOfficial/Unity-JSON) for a more suitable solution for serializing data.
## Installation
* [Add package](https://docs.unity3d.com/Manual/upm-ui-giturl.html) from this git URL: ```com.mrrobin.parser``` or https://github.com/MrRobinOfficial/Unity-Parser.git
Or
* Clone repo and build via Visual Studio as an .DLL
## Quick guide
```c#
using UnityParsers;
```
Avoid regular parse method (Can cause errors if not parse correct!)
```c#
private const string VECTOR3 = "(-50, 30, 100)";
Parsers.Parse(VECTOR3); // This will gives us error! Use TryParse instead for error-proud solution!
```
For an example
```c#
if (Parsers.TryParseVector3(VECTOR3, out UnityEngine.Vector3 result))
{
}
```
Avoid boxing/unboxing if you can. [Read more about it](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/boxing-and-unboxing)
```c#
private const string VECTOR3 = "(-50, 30, 100)";
if (Parsers.TryParse(VECTOR3, out object result))
{
// This take more performance because of boxing/unboxing values.
}
```
Tries to convert string with "off" into boolean
```c#
bool value = Parsers.ParseBoolean("off"); // This will return false
```
Tries to convert string with "bytes color format" into Color32
```c#
private const string COLOR_32 = "(255, 0, 0)";
Parsers.TryParseColor32(COLOR_32, out var color32); // Will return value as Color32
```
