Class Vector2Serializer
Type serializer for UnityEngine.Vector2 values. Writes and reads the two single-precision
components x and y as a JSON object with named properties. Unknown properties
encountered during read are silently skipped via Skip().
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public sealed class Vector2Serializer : TypeSerializerBase<Vector2>, ITypeSerializer<Vector2>, ITypeSerializer
Remarks
The serialized JSON format is {"x": float, "y": float}. Missing component
properties default to 0 on deserialization.
Use the shared Instance singleton rather than creating new instances;
Vector2Serializer carries no mutable state and is safe to share across threads.
Fields
Instance
Shared, reusable singleton instance of Vector2Serializer.
Prefer this over allocating a new instance wherever a Vector2Serializer is needed.
Declaration
public static readonly Vector2Serializer Instance
Field Value
| Type | Description |
|---|---|
| Vector2Serializer |
Methods
Read(IScyllaReader, ISerializationContext)
Reads a UnityEngine.Vector2 from the reader, populating components from a JSON
object's x and y properties.
Declaration
public override Vector2 Read(IScyllaReader reader, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| IScyllaReader | reader | The reader positioned at the start of a JSON object. Never |
| ISerializationContext | context | The active serialization context. Never |
Returns
| Type | Description |
|---|---|
| Vector2 | The deserialized UnityEngine.Vector2. Any missing component defaults to |
Overrides
Write(Vector2, IScyllaWriter, ISerializationContext)
Writes a UnityEngine.Vector2 to the output as a JSON object containing the
x and y float components.
Declaration
public override void Write(Vector2 value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | The UnityEngine.Vector2 to serialize. |
| IScyllaWriter | writer | The writer that receives the serialized output. Never |
| ISerializationContext | context | The active serialization context. Never |