DirAccess.open not work (no path) in build

Godot Version

4.3

Question

I’m using the following piece of code to extract all my levels in app:

func load_levels_from_folder():
	var temp_levels = []
	var dir = DirAccess.open(LEVELS_FOLDER)
	for file in dir.get_files():
		if file.ends_with(".tscn"):  # Filtruj tylko pliki `.tscn`
			temp_levels.append(load(LEVELS_FOLDER + file))
	return temp_levels

Unfortunately, while it works in Godot, it does not work in the build. I guess sth with path is broken - how to fix that? My game is completely broken because no levels are loaded.

That happens because Godot remap/rename the files when export, so you’ll not be able to get a list of valid files like that. You should either save the scene paths hardcoded in an array/dictionary and load them or use ResourceLoader.list_directory (require Godot 4.4 dev 5 or higher)