Version 3.3.1.2

UnitySerializationUtility class

Namespace: Sirenix.Serialization
Assembly: Sirenix.Serialization
public static class UnitySerializationUtility
Provides an array of utility wrapper methods for easy serialization and deserialization of Unity objects of any type. Note that, during serialization, it is always assumed that we are running on Unity's main thread. Deserialization can happen on any thread, and all API's interacting with deserialization are thread-safe.

Note that setting the IndexReferenceResolver on contexts passed into methods on this class will have no effect, as it will always be set to a UnityReferenceResolver.

Inheritance
  • System.Object
  • UnitySerializationUtility

Fields

SerializeReferenceAttributeType
public static readonly Type SerializeReferenceAttributeType

Properties

ForceEditorModeSerialization
Whether to always force editor mode serialization. This member only exists in the editor.
public static bool ForceEditorModeSerialization { get; set; }

Methods

CreateDefaultUnityInitializedObject(Type)
Creates an object with default values initialized in the style of Unity; strings will be "", classes will be instantiated recursively with default values, and so on.
public static object CreateDefaultUnityInitializedObject(Type type)
Parameters
System.Type type

Returns
System.Object

DeserializePrefabModifications(List<String>, List<Object>)
Not yet documented.
public static List<PrefabModification> DeserializePrefabModifications(List<string> modifications, List<Object> referencedUnityObjects)
Parameters
System.Collections.Generic.List<System.String> modifications

System.Collections.Generic.List<UnityEngine.Object> referencedUnityObjects

Returns
System.Collections.Generic.List<PrefabModification>

DeserializeUnityObject(Object, IDataReader)
Not yet documented.
public static void DeserializeUnityObject(Object unityObject, IDataReader reader)
Parameters
UnityEngine.Object unityObject

Sirenix.Serialization.IDataReader reader

DeserializeUnityObject(Object, ref SerializationData, DeserializationContext)
Not yet documented.
public static void DeserializeUnityObject(Object unityObject, ref SerializationData data, DeserializationContext context = null)
Parameters
UnityEngine.Object unityObject

SerializationData data

DeserializationContext context

DeserializeUnityObject(Object, ref Byte[], ref List<Object>, DataFormat, DeserializationContext)
Not yet documented.
public static void DeserializeUnityObject(Object unityObject, ref byte[] bytes, ref List<Object> referencedUnityObjects, DataFormat format, DeserializationContext context = null)
Parameters
UnityEngine.Object unityObject

System.Byte[] bytes

System.Collections.Generic.List<UnityEngine.Object> referencedUnityObjects

DataFormat format

DeserializationContext context

DeserializeUnityObject(Object, ref String, ref List<Object>, DataFormat, DeserializationContext)
Not yet documented.
public static void DeserializeUnityObject(Object unityObject, ref string base64Bytes, ref List<Object> referencedUnityObjects, DataFormat format, DeserializationContext context = null)
Parameters
UnityEngine.Object unityObject

System.String base64Bytes

System.Collections.Generic.List<UnityEngine.Object> referencedUnityObjects

DataFormat format

DeserializationContext context

GetRegisteredPrefabModifications(Object)
Not yet documented.
public static List<PrefabModification> GetRegisteredPrefabModifications(Object obj)
Parameters
UnityEngine.Object obj

Returns
System.Collections.Generic.List<PrefabModification>

GuessIfUnityWillSerialize(MemberInfo)
Guesses whether or not Unity will serialize a given member. This is not completely accurate.
public static bool GuessIfUnityWillSerialize(MemberInfo member)
Parameters
System.Reflection.MemberInfo member

The member to check.

Returns
System.Boolean

True if it is guessed that Unity will serialize the member, otherwise false.

Exceptions
System.ArgumentNullException

The parameter member is null.

GuessIfUnityWillSerialize(Type)
Guesses whether or not Unity will serialize a given type. This is not completely accurate.
public static bool GuessIfUnityWillSerialize(Type type)
Parameters
System.Type type

The type to check.

Returns
System.Boolean

True if it is guessed that Unity will serialize the type, otherwise false.

Exceptions
System.ArgumentNullException

The parameter type is null.

HasModificationsWaitingForDelayedApply(Object)
public static bool HasModificationsWaitingForDelayedApply(Object obj)
Parameters
UnityEngine.Object obj

Returns
System.Boolean

OdinWillSerialize(MemberInfo, Boolean, ISerializationPolicy)
Checks whether Odin will serialize a given member.
public static bool OdinWillSerialize(MemberInfo member, bool serializeUnityFields, ISerializationPolicy policy = null)
Parameters
System.Reflection.MemberInfo member

The member to check.

System.Boolean serializeUnityFields

Whether to allow serialization of members that will also be serialized by Unity.

Sirenix.Serialization.ISerializationPolicy policy

The policy that Odin should be using for serialization of the given member. If this parameter is null, it defaults to Unity.

Returns
System.Boolean

True if Odin will serialize the member, otherwise false.

RegisterPrefabModificationsChange(Object, List<PrefabModification>)
Not yet documented.
public static void RegisterPrefabModificationsChange(Object unityObject, List<PrefabModification> modifications)
Parameters
UnityEngine.Object unityObject

System.Collections.Generic.List<PrefabModification> modifications

SerializePrefabModifications(List<PrefabModification>, ref List<Object>)
Not yet documented.
public static List<string> SerializePrefabModifications(List<PrefabModification> modifications, ref List<Object> referencedUnityObjects)
Parameters
System.Collections.Generic.List<PrefabModification> modifications

System.Collections.Generic.List<UnityEngine.Object> referencedUnityObjects

Returns
System.Collections.Generic.List<System.String>

SerializeUnityObject(Object, IDataWriter, Boolean)
Not yet documented.
public static void SerializeUnityObject(Object unityObject, IDataWriter writer, bool serializeUnityFields = false)
Parameters
UnityEngine.Object unityObject

Sirenix.Serialization.IDataWriter writer

System.Boolean serializeUnityFields

SerializeUnityObject(Object, ref SerializationData, Boolean, SerializationContext)
Not yet documented.
public static void SerializeUnityObject(Object unityObject, ref SerializationData data, bool serializeUnityFields = false, SerializationContext context = null)
Parameters
UnityEngine.Object unityObject

SerializationData data

System.Boolean serializeUnityFields

SerializationContext context

SerializeUnityObject(Object, ref Byte[], ref List<Object>, DataFormat, Boolean, SerializationContext)
Not yet documented.
public static void SerializeUnityObject(Object unityObject, ref byte[] bytes, ref List<Object> referencedUnityObjects, DataFormat format, bool serializeUnityFields = false, SerializationContext context = null)
Parameters
UnityEngine.Object unityObject

System.Byte[] bytes

System.Collections.Generic.List<UnityEngine.Object> referencedUnityObjects

DataFormat format

System.Boolean serializeUnityFields

SerializationContext context

SerializeUnityObject(Object, ref String, ref List<Object>, DataFormat, Boolean, SerializationContext)
Not yet documented.
public static void SerializeUnityObject(Object unityObject, ref string base64Bytes, ref List<Object> referencedUnityObjects, DataFormat format, bool serializeUnityFields = false, SerializationContext context = null)
Parameters
UnityEngine.Object unityObject

System.String base64Bytes

System.Collections.Generic.List<UnityEngine.Object> referencedUnityObjects

DataFormat format

System.Boolean serializeUnityFields

SerializationContext context