Class LayerMaskSerializer
Type serializer for UnityEngine.LayerMask values. Persists the mask as its underlying 32-bit signed integer bitmask via WriteInt(int), preserving all layer bits exactly.
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public sealed class LayerMaskSerializer : TypeSerializerBase<LayerMask>, ITypeSerializer<LayerMask>, ITypeSerializer
Remarks
A UnityEngine.LayerMask is stored as a plain integer, not as a JSON object with named layer names, for two reasons: layer names are project-specific and may differ across environments, and the integer representation is more compact and reliable for cross-project or runtime serialization.
Use the shared Instance singleton rather than creating new instances;
LayerMaskSerializer carries no mutable state and is safe to share across threads.
Fields
Instance
Shared, reusable singleton instance of LayerMaskSerializer.
Prefer this over allocating a new instance wherever a LayerMaskSerializer is needed.
Declaration
public static readonly LayerMaskSerializer Instance
Field Value
| Type | Description |
|---|---|
| LayerMaskSerializer |
Methods
Read(IScyllaReader, ISerializationContext)
Reads a 32-bit integer from the reader and wraps it in a UnityEngine.LayerMask.
Declaration
public override LayerMask Read(IScyllaReader reader, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| IScyllaReader | reader | The reader positioned at an integer token. Never |
| ISerializationContext | context | The active serialization context. Never |
Returns
| Type | Description |
|---|---|
| LayerMask | The deserialized UnityEngine.LayerMask with its bitmask set to the read integer value. |
Overrides
Write(LayerMask, IScyllaWriter, ISerializationContext)
Writes the raw integer bitmask of value to the output via
WriteInt(int).
Declaration
public override void Write(LayerMask value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| LayerMask | value | The UnityEngine.LayerMask whose integer bitmask to serialize. |
| IScyllaWriter | writer | The writer that receives the serialized token. Never |
| ISerializationContext | context | The active serialization context. Never |