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

Add plugin hot-reload and reload shortcut support #11612

Open
gdevgodot opened this issue Jan 19, 2025 · 4 comments
Open

Add plugin hot-reload and reload shortcut support #11612

gdevgodot opened this issue Jan 19, 2025 · 4 comments

Comments

@gdevgodot
Copy link

gdevgodot commented Jan 19, 2025

Describe the project you are working on

I am currently working on a plugin-based development workflow within the Godot Editor. As part of this project, I frequently make changes to the plugin’s code or structure, and I would like to see those changes reflected immediately within the editor without reloading the entire project.

Describe the problem or limitation you are having in your project

Currently, in Godot, when I make changes to a plugin, I must manually disable and re-enable the plugin for the changes to take effect. This process it's a bit time-consuming and disrupts the workflow, especially when I am iterating on the plugin and need to frequently test updates. Having to disable and enable plugins for each change makes development less efficient and can hinder the overall experience.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I propose the addition of a feature to support hot-reloading of plugins within the Godot Editor, which would allow changes to be applied without needing to manually disable and re-enable the plugin. This feature could also include the ability to trigger the reload via a shortcut, making the process more streamlined and reducing the friction in the development cycle.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

This feature would likely involve a function or method that allows the editor to unload and reload a plugin dynamically. The feature could be triggered through a keyboard shortcut.

Here is an example of how the feature could work programmatically:

func reload_plugin():
    var editor_interface = get_editor_interface()
    
    # Deactivate the plugin
    editor_interface.set_plugin_enabled("MyPlugin", false)
    
    # Wait until the plugin is completely unloaded (if needed)
    while editor_interface.is_plugin_enabled("MyPlugin"):
        await get_tree().create_timer(0.1).timeout
    
    # Reactivate the plugin to apply changes
    editor_interface.set_plugin_enabled("MyPlugin", true)

If this enhancement will not be used often, can it be worked around with a few lines of script?

Currently, there is no reliable workaround using scripts to reload plugins in Godot, as the method of manually toggling plugins via code (such as set_plugin_enabled) does not work as expected in some cases. This makes it impractical for developers to implement their own solution for hot-reloading plugins. A dedicated hot-reload feature would provide a seamless workflow and avoid the need for these workarounds, ensuring changes to plugins are applied instantly without requiring manual intervention or restarting the editor.

Is there a reason why this should be core and not an add-on in the asset library?

This feature would be good for plugin development and would significantly enhance the efficiency of iterating on plugins within the Godot Editor. Having it as part of the core editor would provide a native solution for all plugin developers. Additionally, integrating this feature directly into the editor would ensure that it works consistently across all plugins and would likely benefit a large portion of the Godot development community.

@Calinou Calinou changed the title Plugin Hot-Reload and Shortcut Support Add plugin hot-reload and reload shortcut support Jan 20, 2025
@arkology
Copy link

You may want to look at this one https://github.com/godot-extended-libraries/godot-plugin-refresher

@KoBeWi
Copy link
Member

KoBeWi commented Jan 20, 2025

the method of manually toggling plugins via code (such as set_plugin_enabled) does not work as expected in some cases

How? It's the same method that editor uses when you toggle the checkbox.

@gdevgodot
Copy link
Author

the method of manually toggling plugins via code (such as set_plugin_enabled) does not work as expected in some cases

How? It's the same method that editor uses when you toggle the checkbox.

Godot crashes sometimes this way.

@KoBeWi
Copy link
Member

KoBeWi commented Jan 20, 2025

That's a bug then. If you know how to reproduce it, it can be fixed.

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

No branches or pull requests

4 participants