docs.unity3d.com
    Show / Hide Table of Contents

    Class AssetPack

    Stores asset metadata (guid and fileId) for assets associated with a JSON-serialized scene This type is used as a look up table for asset objects, and can be used to build an AssetBundle for loading scene assets in player builds

    Inheritance
    Object
    Object
    ScriptableObject
    AssetPack
    Inherited Members
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(String)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: Unity.RuntimeSceneSerialization
    Syntax
    public class AssetPack : ScriptableObject, ISerializationCallbackReceiver

    Properties

    AssetCount

    The number of assets and prefabs in in this AssetPack

    Declaration
    public int AssetCount { get; }
    Property Value
    Type Description
    Int32

    SceneAsset

    The associated SceneAsset for this AssetPack

    Declaration
    public Object SceneAsset { get; set; }
    Property Value
    Type Description
    Object

    Methods

    Clear()

    Clear all asset references in this AssetPack

    Declaration
    public void Clear()

    GetAsset(String, Int64)

    Get an asset based on its guid and fileId

    Declaration
    public Object GetAsset(string guid, long fileId)
    Parameters
    Type Name Description
    String guid
    Int64 fileId
    Returns
    Type Description
    Object

    GetAssetMetadata(Object, out String, out Int64, Boolean)

    Get the guid and sub-asset index for a given asset Also adds the asset to the asset pack in the editor

    Declaration
    public void GetAssetMetadata(Object obj, out string guid, out long fileId, bool warnIfMissing)
    Parameters
    Type Name Description
    Object obj

    The asset object

    String guid

    The guid for this asset in the AssetDatabase

    Int64 fileId

    The fileId within the asset for the object

    Boolean warnIfMissing

    Whether to print warnings if the object could not be found (suppress if this might be a scene object and metadata doesn't exist)

    RegisterPrefabFactory(IPrefabFactory)

    Register an IPrefabFactory to instantiate prefabs which were not saved along with the scene

    Declaration
    public void RegisterPrefabFactory(IPrefabFactory factory)
    Parameters
    Type Name Description
    IPrefabFactory factory

    An IPrefabFactory which can instantiate prefabs by guid

    TryInstantiatePrefab(String, Transform)

    Instantiate the prefab with the given guid, if it is in the asset pack or can be created by a registered factory

    Declaration
    public GameObject TryInstantiatePrefab(string prefabGuid, Transform parent)
    Parameters
    Type Name Description
    String prefabGuid

    The guid of the prefab to be instantiated

    Transform parent

    The parent object to be used when calling Instantiate

    Returns
    Type Description
    GameObject

    The instantiated prefab, or null if one was not instantiated

    UnregisterPrefabFactory(IPrefabFactory)

    Unregister an IPrefabFactory

    Declaration
    public void UnregisterPrefabFactory(IPrefabFactory factory)
    Parameters
    Type Name Description
    IPrefabFactory factory

    The IPrefabFactory to be unregistered

    Explicit Interface Implementations

    ISerializationCallbackReceiver.OnAfterDeserialize()

    Called after serialization to set up dictionaries from lists

    Declaration
    void ISerializationCallbackReceiver.OnAfterDeserialize()
    Implements
    ISerializationCallbackReceiver.OnAfterDeserialize()

    ISerializationCallbackReceiver.OnBeforeSerialize()

    Called before serialization to set up lists from dictionaries

    Declaration
    void ISerializationCallbackReceiver.OnBeforeSerialize()
    Implements
    ISerializationCallbackReceiver.OnBeforeSerialize()
    Back to top
    Terms of use
    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