How to make custom Aseprite EditorImportPlugin properly save generated image resource.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rabbit

Title mostly describes the issue; I’m writing a custom importer for Aseprite files, and I’ve already written the actual image generation code (takes the Aseprite file, parses and processes it, turning it into an Image), but I don’t know how to make the EditorImportPlugin save the generated Image.

What I’m doing right now, is taking the generated Image, creating an ImageTexture from it using ImageTexture.create_from_image(an_image) and saving that in my custom EditorImportPlugin. It saves it with extension “tex” and returns “ImageTexture” from get_resource_type().

Unfortunately this doesn’t seem to be the right way to go about it, as Godot doesn’t handle the imported resource properly. If the Aseprite file is modified (automatic reimport), or you manually force a reimport, nothing happens. For Godot to recognize any changes, you have to fully quit the editor and start it back up.

Originally I wanted to attempt to import as a StreamTexture (as that what all other image types import as), but looking through the engine source, it isn’t fully exposed to GDScript, so it’s not possible to actually generate a new StreamTexture. All you can do is create a new instance that loads an existing one saved to disk.

Anyone that can chime in on the correct way to handle this importer, I’d appreciate it.