Class SerializationUtils
Inheritance
SerializationUtils
Syntax
public static class SerializationUtils
Methods
DeserializeScene(String, ref SceneContainer, JsonSerializationParameters)
Declaration
public static void DeserializeScene(string jsonString, ref SceneContainer value, JsonSerializationParameters parameters = null)
Parameters
FromJson<T>(String)
Alternative version of JsonSerialization.FromJson which uses JsonSceneReader
Declaration
public static T FromJson<T>(string jsonString)
Parameters
| Type |
Name |
Description |
| String |
jsonString |
The Json string to be deserialized
|
Returns
Type Parameters
| Name |
Description |
| T |
The type of value represented by the Json string
|
Exceptions
| Type |
Condition |
| Exception |
Thrown if serialization failed
|
GetTargetObjectWithComponentIndex(GameObject, Int32)
Declaration
public static Object GetTargetObjectWithComponentIndex(this GameObject gameObject, int index)
Parameters
Returns
Declaration
public static Transform GetTransformAtPath(this Transform root, string path)
Parameters
Returns
Declaration
public static string GetTransformPath(this Transform root, Transform target)
Parameters
Returns
Declaration
public static void GetTransformPathAndComponentIndex(Transform root, Object target, out string transformPath, out int componentIndex)
Parameters
ImportScene(String, AssetPack)
Declaration
public static void ImportScene(string jsonText, AssetPack assetPack = null)
Parameters
InvokeGenericMethodWrapper(Object, SerializationUtils.IGenericMethodFactory)
Invoke a generic method with a UnityObject as an argument based on its specific type
This is currently implemented for the GameObject type. All Component types in loaded assemblies will be
implemented by appending code via the PrefabOverrideAssemblyPostProcessor
Declaration
public static void InvokeGenericMethodWrapper(Object argument, SerializationUtils.IGenericMethodFactory methodFactory)
Parameters
| Type |
Name |
Description |
| Object |
argument |
The UnityObject which will be passed as an argument, and whose type will be used to
determine the specific generic implementation to use
|
| SerializationUtils.IGenericMethodFactory |
methodFactory |
A factory object which can provide a generic method delegate on demand
|
RegisterPropertyBag(Type)
Register a reflected property bag which is compatible with scene serialization for the given type
Declaration
public static void RegisterPropertyBag(Type type)
Parameters
| Type |
Name |
Description |
| Type |
type |
The type which will be represented by the property bag
|
RegisterPropertyBagRecursively(Type)
Register a reflected property bag which is compatible with scene serialization for the given type and the
types of its properties, and their properties recursively
Declaration
public static void RegisterPropertyBagRecursively(Type type)
Parameters
| Type |
Name |
Description |
| Type |
type |
The type which will used to create the property bags
|
SerializeScene(Scene)
Serialize a scene to Json
Scene must be loaded and valid
Declaration
public static string SerializeScene(Scene scene)
Parameters
| Type |
Name |
Description |
| Scene |
scene |
The scene to serialize
|
Returns
| Type |
Description |
| String |
The serialized scene as a Json string
|
SortComponentList(List<Component>, List<KeyValuePair<Component, Boolean>>)
Declaration
public static void SortComponentList(List<Component> components, List<KeyValuePair<Component, bool>> sortedComponents)
Parameters
ToJson<T>(T)
Alternative method to JsonSerialization.ToJson which uses JsonSceneWriter
Use this if you need to support ISerializationCallbacks
Declaration
public static string ToJson<T>(T value)
Parameters
| Type |
Name |
Description |
| T |
value |
The value to serialize
|
Returns
| Type |
Description |
| String |
A string containing the Json serialized representation of value
|
Type Parameters
| Name |
Description |
| T |
The type of the value being serialized
|