How can a plugin be made to reset itself upon save?

Godot Version

v4.3.dev3.official [36e943b6b]

Question

I am trying to make a simple single scene plugin to open up in the Editor panel. Works fine, but what is annoying is having to reset the plugin on every save/change to the scene.

I would like to reset the plugin without having to go into the Project Settings>Plugins nor use the plugin QuickPluginRefresh (works but it is extra steps). My idea is on every Editor save, to call the EditorInterface.set_plugin_enabled() on the plugin itself. Needless to say this does not work probably because it loaded on itself.

Any thoughts if this is even possible? Maybe the plugin can be called from another on-save plugin?

Here is what I get in the Output console:

  editor/editor_node.cpp:3403 - Condition "!p_enabled && !addon_name_to_plugin.has(addon_path)" is true.
  editor/editor_node.cpp:3403 - Condition "!p_enabled && !addon_name_to_plugin.has(addon_path)" is true.
Just Saved!
Just Saved!

This is the Notification code in a @tool scene script.

func _notification(what):
	if what == NOTIFICATION_EDITOR_POST_SAVE:
		EditorInterface.set_plugin_enabled("res://addons/myplugin", false)
        EditorInterface.set_plugin_enabled("res://addons/myplugin", true)
		print("Just Saved!")

Solved it. Do not include path to the plugin. Just the plugin name.

func _notification(what):
	if what == NOTIFICATION_EDITOR_POST_SAVE:
		EditorInterface.set_plugin_enabled("myplugin", false)
        EditorInterface.set_plugin_enabled("myplugin", true)
		print("Just Saved!")

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.