Class ScriptableObjectPropertyContainer<TContainer> | Entities | 0.2.0-preview.18
docs.unity3d.com
    Show / Hide Table of Contents

    Class ScriptableObjectPropertyContainer<TContainer>

    Provides the necessary implementation to use properties and serialization with a of type TContainer.

    Inheritance
    Object
    ScriptableObjectPropertyContainer<TContainer>
    BuildPipeline
    ComponentContainer<TContainer, TComponent>
    Namespace: Unity.Build
    Syntax
    [Serializable]
    public abstract class ScriptableObjectPropertyContainer<TContainer> : ScriptableObject, ISerializationCallbackReceiver where TContainer : ScriptableObjectPropertyContainer<TContainer>
    Type Parameters
    Name Description
    TContainer

    The type of the container.

    Methods

    CreateAsset(String, Action<TContainer>)

    Create a new asset instance saved to disk.

    Declaration
    public static TContainer CreateAsset(string assetPath, Action<TContainer> mutator = null)
    Parameters
    Type Name Description
    String assetPath

    The location where to create the asset.

    Action<TContainer> mutator

    Optional mutator that can be used to modify the asset.

    Returns
    Type Description
    TContainer

    The new asset instance.

    CreateInstance(Action<TContainer>)

    Create a new asset instance.

    Declaration
    public static TContainer CreateInstance(Action<TContainer> mutator = null)
    Parameters
    Type Name Description
    Action<TContainer> mutator

    Optional mutator that can be used to modify the asset.

    Returns
    Type Description
    TContainer

    The new asset instance.

    DeserializeFromJson(TContainer, String)

    Deserialize from a JSON String into the container.

    Declaration
    public static bool DeserializeFromJson(TContainer container, string json)
    Parameters
    Type Name Description
    TContainer container

    The container to deserialize into.

    String json

    The JSON string to deserialize from.

    Returns
    Type Description
    Boolean

    true if the operation is successful, false otherwise.

    DeserializeFromPath(TContainer, String)

    Deserialize from a file into the container.

    Declaration
    public static bool DeserializeFromPath(TContainer container, string path)
    Parameters
    Type Name Description
    TContainer container

    The container to deserialize into.

    String path

    The file path to deserialize from.

    Returns
    Type Description
    Boolean

    true if the operation is successful, false otherwise.

    DeserializeFromStream(TContainer, Stream)

    Deserialize from a stream into the container.

    Declaration
    public static bool DeserializeFromStream(TContainer container, Stream stream)
    Parameters
    Type Name Description
    TContainer container

    The container to deserialize into.

    Stream stream

    The stream to deserialize from.

    Returns
    Type Description
    Boolean

    true if the operation is successful, false otherwise.

    LoadAsset(GUID)

    Load an asset from the specified asset .

    Declaration
    public static TContainer LoadAsset(GUID assetGuid)
    Parameters
    Type Name Description
    GUID assetGuid

    The asset to load from.

    Returns
    Type Description
    TContainer

    The loaded asset if successful, null otherwise.

    LoadAsset(String)

    Load an asset from the specified asset path.

    Declaration
    public static TContainer LoadAsset(string assetPath)
    Parameters
    Type Name Description
    String assetPath

    The asset path to load from.

    Returns
    Type Description
    TContainer

    The loaded asset if successful, null otherwise.

    OnAfterDeserialize()

    Declaration
    public void OnAfterDeserialize()

    OnBeforeSerialize()

    Declaration
    public void OnBeforeSerialize()

    OnEnable()

    Declaration
    public void OnEnable()

    Reset()

    Reset this asset in preparation for deserialization.

    Declaration
    protected virtual void Reset()

    RestoreAsset()

    Restore this asset from disk.

    Declaration
    public bool RestoreAsset()
    Returns
    Type Description
    Boolean

    true if the operation is successful, false otherwise.

    Sanitize()

    Sanitize this asset after deserialization.

    Declaration
    protected virtual void Sanitize()

    SaveAsset(String)

    Save this asset to disk. If no asset path is provided, asset is saved at its original location.

    Declaration
    public bool SaveAsset(string assetPath = null)
    Parameters
    Type Name Description
    String assetPath

    Optional file path where to save the asset.

    Returns
    Type Description
    Boolean

    true if the operation is successful, false otherwise.

    SerializeToJson()

    Serialize this container to a JSON String.

    Declaration
    public string SerializeToJson()
    Returns
    Type Description
    String

    The container as a JSON String if the serialization is successful, null otherwise.

    SerializeToPath(String)

    Serialize this container to a file.

    Declaration
    public void SerializeToPath(string path)
    Parameters
    Type Name Description
    String path

    The file path to write into.

    SerializeToStream(Stream)

    Serialize this container to a stream.

    Declaration
    public void SerializeToStream(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    The stream the serialize into.

    Events

    AssetChanged

    Event invoked when the asset changed on disk.

    Declaration
    public static event Action<TContainer> AssetChanged
    Event Type
    Type Description
    Action<TContainer>

    JsonVisitorRegistration

    Event invoked when the container registers used for serialization. It provides an opportunity to register additional property visitor adapters.

    Declaration
    public static event Action<JsonVisitor> JsonVisitorRegistration
    Event Type
    Type Description
    Action<JsonVisitor>
    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