Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autoloaded scene loses their built-in script when upgrading to 4.4 #103439

Conversation

Hilderin
Copy link
Contributor

@Hilderin Hilderin commented Mar 1, 2025

I'm not 100% certain why the modifications from #102636 afftected this issue but I think the issue is caused because with the modifications, the Player script in the MVP is now valid at the moment of the upgrade, causing the autoload script (BulletManager) to load while loading the Player script during the upgrade process.

In the GDScriptCache::get_shallow_script, the BulletManager script resource (which is an embedded script into the scene) is created but without it's scene unique id.

Image

That causes the save of the bullet_manager.tscn to create a new embedded script with a new id when resaving it in the upgrade process.

I fixed the issue by using the ResourceFormatLoader::CACHE_MODE_REPLACE cache mode to the ResourceLoader::load in UIDUpgradeTool::finish_upgrade:

Ref<Resource> res = ResourceLoader::load(file_path, "", ResourceFormatLoader::CACHE_MODE_REPLACE);

That forces the scene and the script to be reloaded completely from the disk during the upgrade progress.

@matheusmdx
Copy link
Contributor

Tested the artifact, works as expected 👍

@akien-mga akien-mga merged commit d57296f into godotengine:master Mar 2, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autoloaded scene loses their built-in script when upgrading from 4.3 to 4.4
3 participants