使用此函数,你可以从引用资产的(字符串)名称中获取类型。将返回下面列出的 常量 之一。
asset_get_type(name);
参数 描述 name 获取的游戏资产的(字符串)类型名称。
常量
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));
}
上面的代码检查动态创建的资产名称,以查看资产的类型是否正确。如果不正确,则显示调试消息,否则使用资产名称将资产分配给实例。