With this function you can get the type of asset being referenced from its name (a string). One of the constants listed below will be returned.
asset_get_type(name);
| Argument | Description |
|---|---|
| name | The name of the game asset to get the type of (a string). |
Constant
Constant Description asset_object The given name refers to an object. asset_sprite The given name refers to a sprite. asset_sound The given name refers to a sound. asset_room The given name refers to a room. asset_tiles The given name refers to a tile set. asset_path The given name refers to a path. asset_script The given name refers to a script. asset_font The given name refers to a font. asset_timeline The given name refers to a time line. asset_shader The given name refers to a shader. asset_animationcurve The given name refers to an Animation Curve. asset_sequence The given name refers to a Sequence. asset_unknown The given name refers to an asset that either does not exist, or is not one of the above listed.
if asset_get_type("pth_Path_" + string(global.Game)) == asset_unknown
{
show_debug_message("Path doesn't exist!!!");
}
else
{
path_index = asset_get_index("pth_Path_" + string(global.Game));
}
The above code checks a dynamically created asset name to see if the asset is of the correct type. If it is not, then a debug message will be shown, otherwise the asset name is used to assign the asset to the instance.