ResourceFormatSaver
继承: RefCounted
< Object
Saves a specific resource type to a file.
描述
The engine can save resources when you do it from the editor, or when you use the ResourceSaver
singleton. This is accomplished thanks to multiple ResourceFormatSaver s, each handling its own format and called automatically by the engine.
By default, Godot saves resources as .tres
(text-based), .res
(binary) or another built-in format, but you can choose to create your own format by extending this class. Be sure to respect the documented return types and values. You should give it a global class name with class_name
for it to be registered. Like built-in ResourceFormatSavers, it will be called automatically when saving resources of its recognized type(s). You may also implement a ResourceFormatLoader
.
方法
PackedStringArray | _get_recognized_extensions ( resource: Resource ) virtual1 const2 |
bool | _recognize ( resource: Resource ) virtual1 const2 |
bool | _recognize_path ( resource: Resource , path: String ) virtual1 const2 |
Error | _save ( resource: Resource , path: String , flags: int ) virtual1 |
Error | _set_uid ( path: String , uid: int ) virtual1 |
方法说明
PackedStringArray
_get_recognized_extensions ( resource: Resource
) virtual1 const2
Returns the list of extensions available for saving the resource object, provided it is recognized (see _recognize
).
bool
_recognize ( resource: Resource
) virtual1 const2
Returns whether the given resource object can be saved by this saver.
bool
_recognize_path ( resource: Resource
, path: String
) virtual1 const2
Returns true
if this saver handles a given save path and false
otherwise.
If this method is not implemented, the default behavior returns whether the path's extension is within the ones provided by _get_recognized_extensions
.
Error _save ( resource: Resource
, path: String
, flags: int
) virtual1
Saves the given resource object to a file at the target path
. flags
is a bitmask composed with SaverFlags constants.
Returns @GlobalScope.OK
on success, or an Error constant in case of failure.
Error _set_uid ( path: String
, uid: int
) virtual1
Sets a new UID for the resource at the given path
. Returns @GlobalScope.OK
on success, or an Error constant in case of failure.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。