Class RectSerializer
Type serializer for UnityEngine.Rect values (axis-aligned rectangle defined by position
and dimensions as floats). Writes and reads the x, y, width, and
height components as a JSON object with named properties. Unknown properties
encountered during read are silently skipped.
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public sealed class RectSerializer : TypeSerializerBase<Rect>, ITypeSerializer<Rect>, ITypeSerializer
Remarks
The serialized JSON format is
{"x": float, "y": float, "width": float, "height": float}.
All components default to 0 when absent during deserialization.
For integer-based rectangle representation, see RectIntSerializer.
Use the shared Instance singleton rather than creating new instances;
RectSerializer carries no mutable state and is safe to share across threads.
Fields
Instance
Shared, reusable singleton instance of RectSerializer.
Prefer this over allocating a new instance wherever a RectSerializer is needed.
Declaration
public static readonly RectSerializer Instance
Field Value
| Type | Description |
|---|---|
| RectSerializer |
Methods
Read(IScyllaReader, ISerializationContext)
Reads a UnityEngine.Rect from the reader, populating components from a JSON object's
x, y, width, and height properties.
Declaration
public override Rect 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 |
|---|---|
| Rect | The deserialized UnityEngine.Rect. Any missing component defaults to |
Overrides
Write(Rect, IScyllaWriter, ISerializationContext)
Writes a UnityEngine.Rect to the output as a JSON object containing the
x, y, width, and height float components.
Declaration
public override void Write(Rect value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | value | The UnityEngine.Rect to serialize. |
| IScyllaWriter | writer | The writer that receives the serialized output. Never |
| ISerializationContext | context | The active serialization context. Never |