Tool script runs before plugin is enabled

Godot Version

v4.2.1.stable.official [b09f793f5]

Question

I have an EditorPlugin that instantiates a scene that is passed to add_control_to_dock(). Without @tool the docked scene script does not run. If @tool is added the scene gets instantiated by the editor even when the plugin is disabled. The problem is the scene code relies on initializations done by the EditorPlugin script. Running the scene script before the EditorPlugin script causes the editor to crash.

Are @tool scenes always run by the editor on startup? Is there a work around?

Thanks.

1 Like

I’ve found a rather ugly solution. I placed following check in the scene script’s _init(), _enter_tree(), _ready(), _exit_tree().

	if !EditorInterface.is_plugin_enabled("plugin_folder_name"):
		return;

Is there a better solution?

You should first check if it is in the editor.

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