Class Vector2Json
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
readerUtf8JsonReaderThe JSON reader, at the start of the array.
typeToConvertTypeThe type to read. The method does not use it.
optionsJsonSerializerOptionsThe 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
writerUtf8JsonWriterThe JSON writer.
valueVector2The vector to write.
optionsJsonSerializerOptionsThe serializer options. The method does not use them.