Recently I ran across an issue where I resolved a bug in my game in the editor, but after export the bug was still present. I found that if I changed the name of the file and exported again, the bug was fixed.
At first I thought this was a caching issue and tried removing and readding the file to the project, renaming the file to something arbitrary, and back to the original. I went through the whole process of clearing the .godot cache, which didn’t resolve the issue. Then I wiped my local project, and repulled everything from my repo. The issue remained.
I started digging into each aspect of the exports and performing the headless exports one by one watching the output, and that’s where I found the issue. My project is broken out into several exports for the various assets so that a change in a script doesn’t require the full download of the music or graphical assets.
What I found is that the autoload or singleton scripts are automatically added to each and every export, even if not selected (I’m guessing because of “and required dependencies”), and that in the loading process of those packs, since they weren’t be updated and only my main pack was, the old unmodified script was taking precedence. Further illustrated by changing the file name of the script, performing a new export and the bug being resolved.
There are a couple ways to fix this. I can create yet another pack that contains just the scripts, and export that the same way I do the other files, and ensure the script pack is loaded last, thereby taking precedence, or (and what I’m doing currently), is loading the main game pack once all the other packs have been loaded, thus ensuring the newest scripts have precedence. It should be noted this is how you can add DLC, patches, etc.
All in all this was a head scratcher at the start since I’m a relatively new game dev and learning as I go. 😆
Hopefully this will help someone else out there.