asset_get_type

Returns the type of game asset referenced from its name.

Syntax:

GML Code Example

asset_get_type(name);


Argument Description
name The name of the game asset to get the type of (a string).


Returns: Constant


Description

With this function you can get the type of asset being referenced from it s name (a string). The following constants are returned:

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_background The given name refers to a background.
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_unknown The given name refers to an asset that either does not exist, or is not one of the above listed.


Example:

GML Code Example

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.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here