Converting scene to plugin?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Footurist

Is anybody aware of a convenient way to convert a scene to an EditorPlugin/custom node? Right now I’m just adding the code, that’s needed to instance all the nodes in the scene, but I wondered if there is something more convenient?

:bust_in_silhouette: Reply From: gswashburn

Take a look at my Snippet Editor Plugin Code.
https://github.com/gswashburn/Snippets-EditorPlugin

I used a scene in my editor plugin. The only issue I had, was accessing certain Editor Only settings, but I passed values to the scene from editorplugin script. (see Below) You can ref variables in other scenes.

func _enter_tree():	
	# First load the dock scene and instance it:
	dock = preload("res://addons/snippets_plugin/snippets_dock.tscn").instance()
	# Add the loaded scene to the docks:
	add_control_to_dock( EditorPlugin.DOCK_SLOT_LEFT_BR, dock)

func get_ext_editor():
	# Check for external editor in Editor Settings
	var ext_editor = ed.get_setting("text_editor/external/exec_path")
	if not ext_editor == "":
		dock.ext_editor_path = ext_editor
	else:
		dock.ext_editor_path = ""