Version 3.3.1.2

Serializer<T> class

Namespace: Sirenix.Serialization
Assembly: Sirenix.Serialization
public abstract class Serializer<T> : Serializer
Serializes and deserializes the type , and wraps serialization and deserialization with all the proper calls to free formatters from tedious boilerplate.

Whenever serializing or deserializing anything, it is *strongly recommended* to use Get<T>() to get a proper wrapping serializer for that type.

NOTE: This class should NOT be inherited from; it is hard-coded into the system.

To extend the serialization system, instead create custom formatters, which are used by the ComplexTypeSerializer<T> class.

Inheritance

Type Parameters

T

The type which the Serializer<T> can serialize and deserialize.

Constructors

Serializer()
protected Serializer()

Methods

FireOnSerializedType()
Fires the event with the T generic argument of the serializer.
[Conditional("UNITY_EDITOR")]
protected static void FireOnSerializedType()
ReadValue(IDataReader)
Reads a value of type .
public abstract T ReadValue(IDataReader reader)
Parameters
Sirenix.Serialization.IDataReader reader

The reader to use.

Returns
T

The value which has been read.

ReadValueWeak(IDataReader)
Reads a value of type weakly, casting it into object. Use this method if you don't know what type you're going to be working with at compile time.
public override object ReadValueWeak(IDataReader reader)
Parameters
Sirenix.Serialization.IDataReader reader

The reader to use.

Returns
System.Object

The value which has been read.

WriteValue(T, IDataWriter)
Writes a value of type .
public void WriteValue(T value, IDataWriter writer)
Parameters
T value

The value to write.

Sirenix.Serialization.IDataWriter writer

The writer to use.

WriteValue(String, T, IDataWriter)
Writes a value of type with a given name.
public abstract void WriteValue(string name, T value, IDataWriter writer)
Parameters
System.String name

The name of the value to write.

T value

The value to write.

Sirenix.Serialization.IDataWriter writer

The writer to use.

WriteValueWeak(String, Object, IDataWriter)
Writes a weakly typed value of type with a given name. Use this method if you don't know what type you're going to be working with at compile time.
public override void WriteValueWeak(string name, object value, IDataWriter writer)
Parameters
System.String name

The name of the value to write.

System.Object value

The value to write.

Sirenix.Serialization.IDataWriter writer

The writer to use.