Class SerializationUtils | Unity Runtime Scene Serialization | 0.1.4-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Class SerializationUtils

    Inheritance
    Object
    SerializationUtils
    Namespace: Unity.RuntimeSceneSerialization
    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
    Type Name Description
    String jsonString
    SceneContainer value
    JsonSerializationParameters 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 Description
    T
    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
    Type Name Description
    GameObject gameObject
    Int32 index
    Returns
    Type Description
    Object

    GetTransformAtPath(Transform, String)

    Declaration
    public static Transform GetTransformAtPath(this Transform root, string path)
    Parameters
    Type Name Description
    Transform root
    String path
    Returns
    Type Description
    Transform

    GetTransformPath(Transform, Transform)

    Declaration
    public static string GetTransformPath(this Transform root, Transform target)
    Parameters
    Type Name Description
    Transform root
    Transform target
    Returns
    Type Description
    String

    GetTransformPathAndComponentIndex(Transform, Object, out String, out Int32)

    Declaration
    public static void GetTransformPathAndComponentIndex(Transform root, Object target, out string transformPath, out int componentIndex)
    Parameters
    Type Name Description
    Transform root
    Object target
    String transformPath
    Int32 componentIndex

    ImportScene(String, AssetPack)

    Declaration
    public static void ImportScene(string jsonText, AssetPack assetPack = null)
    Parameters
    Type Name Description
    String jsonText
    AssetPack assetPack

    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
    Type Name Description
    List<Component> components
    List<KeyValuePair<Component, Boolean>> sortedComponents

    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

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023