Show / Hide Table of Contents

Method GetAssetID

| Edit this page View Source

GetAssetID(Type, string)

Finds the AssetID by an asset name at runtime.
The closed matching base type must be used. E.g. for prefabs use GameObject, for Textures use Texture2D etc.
If no asset is found, an invalid AssetID is returned.
Declaration
public AssetID GetAssetID(Type type, string name)
Parameters
Type Name Description
Type type Asset type to search for
string name Asset name to search for
Returns
Type Description
AssetID The AssetID of the searched asset if found, otherwise an invalid AssetID
Exceptions
Type Condition
InvalidOperationException Thrown if the vanilla asset system is not initialized yet
| Edit this page View Source

GetAssetID<T>(string)

Finds the AssetID by an asset name at runtime.
The closed matching base type must be used. E.g. for prefabs use GameObject, for Textures use Texture2D etc.
If no asset is found, an invalid AssetID is returned.
Declaration
public AssetID GetAssetID<T>(string name) where T : UnityEngine.Object
Parameters
Type Name Description
string name Asset name to search for
Returns
Type Description
AssetID
Type Parameters
Name Description
T Asset type to search for
Exceptions
Type Condition
InvalidOperationException Thrown if the vanilla asset system is not initialized yet
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Generated by DocFX
☀
☾