-
Couldn't load subscription status.
- Fork 44
feat: ✨ adds refresh_scene and extend_scene
#378
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
Conversation
removed `append_node_in_scene` and `save_scene` `refresh_scenes` will only work for Godot 4.3 and up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
promising! still need to test later.
do you think this is unit testable?
|
Should be testable, but first, we need to migrate or rebuild the testing for the 4.x branch 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new hope for scene modifications 🚀
Changes to ModLoaderMod
New Methods
static func refresh_scene(scene_path: String) -> void:Refreshes a specific scene by marking it for refresh.
This function is useful if a script extension is not automatically applied. This situation can occur when a script is attached to a preloaded scene. If you encounter issues where your script extension is not working as expected, try to identify the scene to which it is attached and use this method to refresh it. This will reload already loaded scenes and apply the script extension.
🚨
refresh_scenewill only work for Godot 4.3 and up. 🚨static func extend_scene(scene_vanilla_path: String, edit_callable: Callable) -> void:Extends a specific scene by providing a callable function to modify it. The callable receives an instance of the
vanilla_sceneas the first parameter and has to return the modified version.Removed Methods
static func append_node_in_scene(modified_scene: Node, node_name: String = "", node_parent = null, instance_path: String = "", is_visible: bool = true) -> void:Removed without replacement because it was always unintuitive to use. Instead of this method, the scene extension setup can be used to add a node to a scene.
static func save_scene(modified_scene: Node, scene_path: String) -> void:save_scenehas been moved to scene_extension.gd as an internal method used byhandle_scene_extensions()New Class -
_ModLoaderSceneExtensionSimilar to
_ModLoaderScriptExtension, this class encompasses everything related to modifying PackedScenes, with the hope of continuous improvement.Currently, preloaded scenes can't be modified using these methods because
CACHE_MODE_REPLACEloads the scene from file and, with that, wipes any changes stored in the cached instance. For loaded scenes, this should work just fine.💡 Preloaded scenes can be modified by adding the code to the script extension.
Changes to ModLoader
append_node_in_sceneandsave_scene. I think we can remove the other deprecations in a subsequent PR._ModLoaderSceneExtension.refresh_scenes()and_ModLoaderSceneExtension.handle_scene_extensions()at the end of_load_mods()Changes to ModLoaderStore
var scenes_to_refresh := []Stores scene paths that need to be reloaded from file.
var scenes_to_modify := {}Dictionary of callables to modify a specific scene.
Example property:
"scene_path": [Callable, Callable]Example mod_main.gd
Closes #377