Class QuaternionSerializer
Type serializer for UnityEngine.Quaternion values. Writes and reads the four
single-precision floating-point components x, y, z, and w
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 QuaternionSerializer : TypeSerializerBase<Quaternion>, ITypeSerializer<Quaternion>, ITypeSerializer
Remarks
The serialized JSON format is {"x": float, "y": float, "z": float, "w": float}.
The default value of the w component on read is 1 (identity quaternion),
not 0, matching UnityEngine.Quaternion.identity. Missing x, y,
and z components default to 0.
The raw XYZW representation is used rather than Euler angles because it avoids gimbal-lock ambiguity and round-trip precision loss associated with the euler-to-quaternion conversion.
Use the shared Instance singleton rather than creating new instances;
QuaternionSerializer carries no mutable state and is safe to share across threads.
Fields
Instance
Shared, reusable singleton instance of QuaternionSerializer.
Prefer this over allocating a new instance wherever a QuaternionSerializer is needed.
Declaration
public static readonly QuaternionSerializer Instance
Field Value
| Type | Description |
|---|---|
| QuaternionSerializer |
Methods
Read(IScyllaReader, ISerializationContext)
Reads a UnityEngine.Quaternion from the reader, populating components from a JSON
object's x, y, z, and w properties.
Declaration
public override Quaternion 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 |
|---|---|
| Quaternion | The deserialized UnityEngine.Quaternion. The |
Overrides
Write(Quaternion, IScyllaWriter, ISerializationContext)
Writes a UnityEngine.Quaternion to the output as a JSON object containing the
raw x, y, z, and w float components.
Declaration
public override void Write(Quaternion value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | value | The UnityEngine.Quaternion to serialize. |
| IScyllaWriter | writer | The writer that receives the serialized output. Never |
| ISerializationContext | context | The active serialization context. Never |