Exported game does not include neccesary resources

Godot Version

4.2.1

Question

The game works perfectly fine in editor, however apparently a lot of files(including some scenes) aren’t exported along with the game.

In editor, DirAccess recognizes all the resources I have, but many files are missing when exported:

Here’s the loader script:


extends Node

const gameDir = "res://Minigames/games"
var loadedgames : Dictionary = {}
var games = []
var loaded = false
@onready var dir = DirAccess.open(gameDir)
func _ready():
	for i in dir.get_directories():
		var curr = gameDir + '/' + i + '/Main.tscn'
		if(FileAccess.file_exists(curr)):
			loadedgames[i] = load(curr)
			games.push_back(i)
		else:
			print(i + ' has no Main.tscn')

I’ve also selected to “Export all resources”. It doesn’t seem to work at all.

When you export a project with Convert text files to binary (by default enabled) in your project settings the tscn files are not included in the pck file. They get compressed to scn files inside the .godot folder and a .remap file is put in place of the tscn file which indicates where the scn file is.

Other files like png, ogg, wav,gltf,… are also not included. A .import file is put in place of the original files pointing to the imported file inside the .godot folder.

DirAccess and FileAccess don’t take that into account. They just work with the files that are in place.

You will need to take that into account when dealing with these kind of files.

For example, change the if to:

if FileAccess.file_exists(curr+".remap") or FileAccess.file_exists(curr):
    # stuff