How to get/load "imported resources" that work in exported projects?

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

I’m trying to go through every .wav file in my game’s audio folder and turn that into an AudioStreamPlayer.
So I tried to do this with the help of the sample code in the documentation for the Directory class. The documentation also warns you that the source asset of most resources won’t be included in the exported version of the game and to “use ResourceLoader to access imported resources,” and I assumed that meant I could just do ResourceLoader.load() instead of load() so here’s the code:

var directory =

if"res://assets/audio/") != OK:

var file = directory.get_next()
while file != "":
	if file.get_extension() == "wav":
		var sound =
		add_child(sound) = file.get_slice(".", 0) = ResourceLoader.load(directory.get_current_dir() + file)

	file = directory.get_next()

This works fine when testing in editor except, like the documentation warned, the audio doesn’t get loaded in on an exported version of the game. And I can’t find anything in the documentation that tells me how to load the “imported” versions of the resources. So… how can I get the imported versions of resources rather than their “source assets?” The only thing I found on Google just appears to be a bandage solution.

:bust_in_silhouette: Reply From: AALivingMan

Okay so, it seems like while the source files themselves are missing from the directory upon export, you can still reference them with load()… absolutely confused on why it works like this.

The solution was to edit the code to look for .import files instead of .wav, and then when you get to the load function, remove the .import portion of the filename so it’s referencing that wav file rather than its import file. (and I also had to add a file separator inbetween the directory and the file)

directory.get_current_dir() + "/" + file.get_file().replace(".import", "")