Best Way to Import Multiple Files into a Single Resource

Hello, I’m using Godot 4.2.2 and I’m working on a custom ResourceImporter for skills in my game.

I’ve made each skill its own file (because that makes it easy to edit), but I’d like to import all skills into a single SkillDatabase resource.
Mainly this is to help assigning a unique id to each skill to make them easier to reference at runtime.

What would be the best way to do this? Ideally if I import a new skill the SkillDatabase should automatically update/reimport. I want to avoid doing that manually if possible.

A thought I had was to add a “refresh_skill_database” method at the end of the _import method for the skillimporter, but if I import 100 skills at once, I don’t want that method to trigger 100 times.

Thanks in advance

Do you need them in the editor or only at runtime?
If you need them in the editor you could use the NOTIFICATION_EDITOR_PRE_SAVE to run the importer when the project is about to save instead.
Just loop over every file and update the resources that changed there and it should save with the changed resources. Not sure if you can keep a database just with _import.

1 Like

Alright, yeah I think that should work! I’ll look into it. Thanks a bunch.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.