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
Inherited Members
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.OnBeforeSerialize()
Called before serialization to set up lists from dictionaries
Declaration
void ISerializationCallbackReceiver.OnBeforeSerialize()