Question about Resource when exported

Godot Version

4.6

Question

I’ve read somewhere in Documentation that when I export the project, resource’s file name gets changed. I don’t know if I remember it correctly nor I’m sure of my understanding.

So my question is, for example I have a resource located in “res://level_1.tres” and I have a code that loads it “load(‘res://level_1.tres’)”. If I export the game, will the code still work?

when i used my games that used resources - no problem, tho it’s good idea you’ll name everything from small letter due to different platforms might have problems with capitals if i remember on linux or macos, so just that

Yes load will still work perfectly fine; the problem occurs with directory traversal i.e. DirAccess.open() and then dir.list_dir_begin(), and runtime loading such as Image.load(filename). But you shouldn’t do such operations on “res://” and if you must get resources from “res://” as a list you should use ResourceLoader.list_directory() to get all of the paths you expect regardless of export or debug, then use load on that.

For example if you are creating customization in your game you can list a directory full of skins, or even mixed resource types, and populate a in-game menu. If you added more to this pack file through DLC it should similarly populate the in-game menu with the new DLC items too

const CUSTOMIZE_DIR = "res://player_customizations"
for filename in ResourceLoader.list_directory(CUSTOMIZE_DIR):
    if filename.ends_with(".png"):
        var skin_button := Button.new()
        skin_button.icon = load(CUSTOMIZE_DIR.path_join(filename))
        skin_button.text = filename
        add_child(skin_button)

So this means Godot will omit .tres or resource files that it thinks will not be used by the game from the export?

This is a big problem for my game because it uses dynamic filename for my levels because of my level editor. Thank you very much for a detailed respone! :clap:

No, by default exports will include all resources, you can change this setting but you aught to know what you are doing and test the exports.

Files that are not imported resources such as .txt extensions will not be in exports since they aren’t known resources, but you can still change export settings to force their inclusion if you use raw text files.

Thank you very much, I guess I should just test it to know. I’ll do some tests and report back here. Thanks again to everyone who answered, I really appreciate you :100: !

Yes. The filenames get changed on export from .tres to .res, but Godot knows that and does the conversion.

Trying it is the best bet.