Table of Contents

Class Vector2Json

Namespace
PolyMod.Json
Assembly
PolyMod.dll

The JSON converter that reads and writes a UnityEngine.Vector2. The JSON form is an array of two numbers, x and y, for example [0.5, -1].

public class Vector2Json : JsonConverter<Vector2>
Inheritance
JsonConverter<Vector2>
Vector2Json
Inherited Members

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads a JSON array of two numbers and makes a UnityEngine.Vector2 from them.

public override Vector2 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters

reader Utf8JsonReader

The JSON reader, at the start of the array.

typeToConvert Type

The type to read. The method does not use it.

options JsonSerializerOptions

The serializer options. The method does not use them.

Returns

Vector2

The vector with the first number as x and the second number as y.

Exceptions

JsonException

The JSON value is not an array, an item is not a number, or the array does not have exactly two items.

Write(Utf8JsonWriter, Vector2, JsonSerializerOptions)

Writes a UnityEngine.Vector2 as a JSON array of two numbers, x and y.

public override void Write(Utf8JsonWriter writer, Vector2 value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter

The JSON writer.

value Vector2

The vector to write.

options JsonSerializerOptions

The serializer options. The method does not use them.