Class SerializationUtils
A collection of utilities to aid in serialization/deserialization of data from loaded experiences.
Inheritance
Inherited Members
Namespace: Liminal.SDK.Serialization
Assembly: Liminal.SDK.dll
Syntax
public class SerializationUtils
Methods
| Improve this Doc View SourceAddGlobalSerializableTypes(Assembly)
Adds serializable types from the specified assembly to the global type list.
Declaration
public static void AddGlobalSerializableTypes(Assembly asm)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | asm | The Assembly to add serializable types from. |
AddGlobalSerializableTypes(String)
Adds serializable types from the specified loaded assembly to the global type list.
Declaration
public static void AddGlobalSerializableTypes(string asmName)
Parameters
Type | Name | Description |
---|---|---|
System.String | asmName | The name of the loaded assembly to add serializable types from. |
BuildSerializableTypeSet(Assembly)
Builds a System.Collections.Generic.HashSet<T> of System.Type objects from the specified assembly that are either Unity objects or have the Serializable attribute declared.
Declaration
public static HashSet<Type> BuildSerializableTypeSet(Assembly asm)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | asm |
Returns
Type | Description |
---|---|
System.Collections.Generic.HashSet<System.Type> | The hashset of types that was created. |
BuildSerializableTypeSet(String)
Builds a System.Collections.Generic.HashSet<T> of System.Type objects from the specified loaded assembly that are either Unity objects or have the Serializable attribute declared.
Declaration
public static HashSet<Type> BuildSerializableTypeSet(string asmName)
Parameters
Type | Name | Description |
---|---|---|
System.String | asmName | The name of the loaded assembly to build the hashset from. |
Returns
Type | Description |
---|---|
System.Collections.Generic.HashSet<System.Type> | The hashset of types that was created. |
ClearGlobalSerializableTypes()
Clears all types from the global serializable types list.
Declaration
public static void ClearGlobalSerializableTypes()
GetFieldFromHierarchy(Type, String, BindingFlags)
Gets a field from the hierarchy of the suppled type's inheritance chain.
Declaration
public static FieldInfo GetFieldFromHierarchy(Type type, string fieldName, BindingFlags bindingFlags)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type to retrieve the field from. |
System.String | fieldName | The name of the field to retrieve. |
System.Reflection.BindingFlags | bindingFlags | The binding flags of the fields to check. |
Returns
Type | Description |
---|---|
System.Reflection.FieldInfo | The first field with the specified name from the type's inheritance chain, or null if no field with the supplied name exists. |
GetFieldsHierarchy(Type, BindingFlags)
Declaration
public static IEnumerable<FieldInfo> GetFieldsHierarchy(Type type, BindingFlags bindings)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | |
System.Reflection.BindingFlags | bindings |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Reflection.FieldInfo> |
GetUnitySerializableFields(Type)
Declaration
public static IEnumerable<FieldInfo> GetUnitySerializableFields(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Reflection.FieldInfo> |
GetUnitySerializableFieldsHierarchy(Type)
Declaration
public static IEnumerable<FieldInfo> GetUnitySerializableFieldsHierarchy(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Reflection.FieldInfo> |
HasSerializableAttribute(Type)
Indicates if the type is considered serializable. Types are considered serializable if they explicitly declare System.SerializableAttribute.
Declaration
public static bool HasSerializableAttribute(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type to check. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean indicating if the type is considered serializable. |
IsSerializable(FieldInfo)
Indicates if the field is considered serializable. Public fields are always serializable, so long as they are not marked with System.NonSerializedAttribute. All other access levels are only serializable if the explicitly declare the UnityEngine.SerializeField attribute.
Declaration
public static bool IsSerializable(FieldInfo field)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.FieldInfo | field | The field to check. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean indicating if the field is considered serializable. |
IsUnityEventType(Type)
Indicates if the supplied type inherits from UnityEngine.Events.UnityEventBase.
Declaration
public static bool IsUnityEventType(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type to check. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean indicating if the supplied type inherits from UnityEngine.Events.UnityEventBase. |
IsUnityObjectCollectionType(Type)
Indicates if the specified type is an Array or List of Unity objects.
Declaration
public static bool IsUnityObjectCollectionType(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type to check. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean indicating if the specified type is an Array or List of Unity objects. |
IsUnityObjectType(Type)
Indicates if the supplied type inherits from UnityEngine.Object.
Declaration
public static bool IsUnityObjectType(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type to check. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean indicating if the supplied type inherits from UnityEngine.Object. |
IsUnityObjectTypeOrCollectionType(Type)
Indicates if the specified type is a Unity Object type, or an Array or List of Unity objects.
Declaration
public static bool IsUnityObjectTypeOrCollectionType(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type to check. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean indicating if the specified type is a Unity Object type, or an Array or List of Unity objects, |
IsUnitySerializableField(FieldInfo)
Indicates if the specified field is considered serializable by Unity.
Declaration
public static bool IsUnitySerializableField(FieldInfo field)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.FieldInfo | field | The FieldInfo value. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean indicating if the specified field is considered serializable by Unity. |