How do I pass some data from the plugin to it's main scene

Godot Version



I would like to pass/store some data from the, to it’s main panel scene (such as name of plugin. Is there anyway to do that directly without using autoload global or using the file system such as cfg?

Here is my plugin initialization code below. In _enter_tree() it instances a scene and adds it to the EditorInterface screen. Does my MainPanel Instance have access to any data in the Currently I am using environment variables, but I would prefer something cleaner.

extends EditorPlugin

var MainPanel:PackedScene 
var main_panel_instance:Control
var plugin_descriptive_name
var base_dir

func _init():
	var conf =
	plugin_descriptive_name = conf.get_value("plugin", "name")
	MainPanel = load(base_dir+"/main_panel.tscn")
	print("\n\nInitialized!!: ",plugin_descriptive_name)

func _enter_tree():
	main_panel_instance = MainPanel.instantiate()
	# Add the main panel to the editor's main viewport.

func _exit_tree():
	if main_panel_instance:

func _has_main_screen():
	return true

func _make_visible(visible):
	if main_panel_instance:
		main_panel_instance.visible = visible

func _get_plugin_name():
	return plugin_descriptive_name

func _get_plugin_icon():
	# Must return some kind of Texture2D for the icon.
	return get_editor_interface().get_base_control().get_theme_icon("Node", "EditorIcons")



name="My Plugin"
description="Demonstrates how to make a main screen plugin."

If I’m understanding your question correctly, you’ve pretty much already done it.

Your main_panel_instance IS the main panel of your scene, so you could just pass the data into that in your _enter_tree method, as long as it has a variable ready for it. Maybe to make it more extendable you could pass the ConfigFile that loads the cfg file and just use that? Making your conf a property instead of a variable in instance of course.

Does that make sense? Am I misreading the situation?

1 Like

I did not realize it was as simple as that. Thank you!

1 Like