ResourceFormatLoader

Inherits: Reference < Object

类别: 核心

简要说明

从文件加载特定资源类型。

方法

无效

get_dependencies ( String path, String add_types ) virtual

PoolStringArray

get_recognized_extensions ( ) virtual

String

get_resource_type ( String path ) virtual

bool

handles_type ( String typename ) virtual

Variant

load ( String path, String original_path ) virtual

int

rename_dependencies ( String path, String renames ) virtual

描述

godot使用resourceformatloader在编辑器或导出的游戏中加载资源。它们通过 ResourceLoader 或者当加载具有内部依赖关系的资源时。每个文件类型可以作为不同的资源类型加载,因此在引擎中注册了多个ResourceFormatLoader。

扩展这个类允许您定义自己的加载器。请务必遵守记录的返回类型和值。您应该给它一个全局类名 class_name 以便注册。与内置的ResourceFormatLoader一样,加载其处理类型的资源时将自动调用它。您还可以实现 ResourceFormatSaver .

Note: You can also extend EditorImportPlugin if the resource type you need exists but Godot is unable to load its format. Choosing one way over another depends if the format is suitable or not for the final exported game. For example, it's better to import .png textures as .stex (StreamTexture) first, so they can be loaded with better efficiency on the graphics card.

方法说明

  • void get_dependencies ( String path, String add_types ) virtual

如果实现,则获取给定资源的依赖项。如果 add_typestrue ,应附加路径 ::TypeName 在哪里 TypeName 是依赖项的类名。

注: 脚本定义的自定义资源类型 ClassDB ,所以你可能会回来 "Resource" 为了他们。

获取此加载程序可以读取的文件的扩展名列表。

获取与给定路径关联的资源的类名。如果装载机不能处理它,它应该返回 "" .

注: 脚本定义的自定义资源类型 ClassDB ,所以你可能会回来 "Resource" 为了他们。

告诉加载程序可以加载哪个资源类。

注: 脚本定义的自定义资源类型 ClassDB 所以你可以处理 "Resource" 为了他们。

当引擎发现此加载程序兼容时加载资源。如果加载的资源是导入的结果, original_path 将以源文件为目标。返回 Resource 目标成功,或 Error 故障时保持不变。

如果已实现,则重命名给定资源中的依赖项并保存它。 renames 是一本字典 {{ String => String }} 将旧的依赖关系路径映射到新路径。

返回 @GlobalScope.OK 成功,或 Error 故障时保持不变。