Is it possible to restrict ResourceLoader.load() to only resources included in the PCK?

Godot Version

4.8

Question

The main scene of my game displays a logo, then in parallel:

  • Un-hides some (obscured) 3D geometry to force shaders to compile.
  • Calls ResourceLoader.load_threaded_request()to load in a PackedScene containing the actual game.
    Once both complete, it then adds the PackedScene containing the actual game to the tree and runs from there.

I recently did a build and accidentally excluded the PackedScene containing the actual game. To my surprise, running the build in the project directory works (while running it in a subdirectory does not, as it fails to load the PackedScene as confirmed via the console).

I wasn’t expecting a release build (especially one with PCK encryption enabled) to start loading unencrypted resources from disk. Is this something I can block or disable?

(I’m aware that the effectiveness of these measures is very limited as the executable runs on the end-user’s machine and thus the decryption key is distributed alongside the encrypted resources)

Are you using res:// paths in your code?

Yes. As far as I understand it, this is the only way to delay loading of a resource.

Exported games consist of your pack file and a pre-compiled runtime copied into the same directory. It could be that the runtime is compiled in a way that reads local project files if it cannot find a pack file with the same name as itself, that’s somewhat similar to the editor’s runtime. I haven’t experimented or confirm this though. In the end it sounds like odd behavior but it doesn’t affect how you would release your game with the complete pack file.