I'm using a lot of resources in my project so my fales became really confusing very fast. So I want to have some resources with a custom extension. Researching about this I ended up creating those custom ResourceFormatSaver
and ResourceFormatLoader
:
func _save(resource: Resource, path: String, _flags: int) -> int:
if not (resource is Dialogue):
return ERR_INVALID_DATA
var file = FileAccess.open(path, FileAccess.WRITE)
if file:
var result := var_to_str(inst_to_dict(resource))
file.store_string(result)
return OK
return ERR_CANT_OPEN
This method "works" but it turns my resource into a string dictionary, which makes it lose some functionality like opening in the inspector, appearing in the FileSystem or the possibility to drag and drop in an exported
variable of my Resource's type (Dialogue).
So I'm wondering if there is a way to use the same _save()
logic as the one being used by Godot for Resource files. Same thing with _load()
. I don't mind if they are identical since all I want is a regular resource file but with my .dialogue
extension.
Is this possible to do without modifying the engine? Thanks beforehand!