Class Color32Serializer
Type serializer for UnityEngine.Color32 values (32-bit RGBA with byte components in the
range [0, 255]). Writes and reads the four byte components r, g, b,
and a 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 Color32Serializer : TypeSerializerBase<Color32>, ITypeSerializer<Color32>, ITypeSerializer
Remarks
The serialized JSON format is {"r": byte, "g": byte, "b": byte, "a": byte}
with each component in the [0, 255] range. If the alpha property is absent during read,
it defaults to 255 (fully opaque). The r, g, and b
components default to 0 when absent.
For float-based color representation in the [0, 1] range, see ColorSerializer.
Use the shared Instance singleton rather than creating new instances;
Color32Serializer carries no mutable state and is safe to share across threads.
Fields
Instance
Shared, reusable singleton instance of Color32Serializer.
Prefer this over allocating a new instance wherever a Color32Serializer is needed.
Declaration
public static readonly Color32Serializer Instance
Field Value
| Type | Description |
|---|---|
| Color32Serializer |
Methods
Read(IScyllaReader, ISerializationContext)
Reads a UnityEngine.Color32 from the reader, populating components from a JSON
object's r, g, b, and a properties.
Declaration
public override Color32 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 |
|---|---|
| Color32 | The deserialized UnityEngine.Color32. The |
Overrides
Write(Color32, IScyllaWriter, ISerializationContext)
Writes a UnityEngine.Color32 to the output as a JSON object containing the
r, g, b, and a byte components (each in the [0, 255] range).
Declaration
public override void Write(Color32 value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | value | The UnityEngine.Color32 to serialize. |
| IScyllaWriter | writer | The writer that receives the serialized output. Never |
| ISerializationContext | context | The active serialization context. Never |