Editor Plugin: Controls Added Progammatically Not Shown

Godot Version

4.2

Question

So I have been working on an Editor Plugin. And I was trying to programmatically add controls to the scene that was added as a Dock. However nothing renders no matter how many times I enable/disable the plugin from Project Settings. But when I run the dock scene as a game I see the button that was programmatically added.

Here’s the code for the script attached to the dock scene: lpc-generator-godot-plugin/addons/lpccharactergenerator/generator_dock.gd at main · 509dave16/lpc-generator-godot-plugin · GitHub

Screenshots

Generator Dock Blank While Game Has Button

TLDR;

Found that I couldn’t programmatically attach the child nodes from the script attached to the “scene” that I added to the dock slot.

Had to instead make the “add_child” calls from the plugin initialization script(i.e. the one with “_enter_tree” function.

func _enter_tree():
	var packed_scene: PackedScene = load("res://addons/lpccharactergenerator/generator_dock.tscn")
	dock = packed_scene.instantiate()
	
	var button = Button.new()
	button.text = "Hello"
	dock.add_child(button)
	
	add_control_to_dock(DOCK_SLOT_LEFT_UR, dock)

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