![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Algorithmite |
I spent a good amount of time troubleshooting this however I cannot seem to figure it out.
Here is my code. It is a very close match with the “Making main screen plugins” Tutorial as I was trying to make a plugin,however I added a few debug statements.
Here is the code:
main_panel.gd
extends Panel
signal main_button_pressed(value)
func _ready():
print("Debug 4")
$Button.connect("pressed", self, "on_Button_pressed")
func on_Button_pressed():
print("Debug 5")
emit_signal("main_button_pressed", "Hello from main screen!")
func _on_side_button_pressed(value):
print(value)
$Label.text = value
side_panel.gd
extends Panel
signal side_button_pressed(value)
func _ready():
print("Debug 2")
$Button.connect("pressed", self, "on_Button_pressed")
func _on_Button_pressed():
print("Debug 3")
emit_signal("side_button_pressed", "Hello from side panel!")
func _on_main_button_pressed(value):
print(value)
$Label.text = value
main_screen_plugin.gd
tool
extends EditorPlugin
const MainPanel = preload("res://addons/theme_maker/scenes/main_panel.tscn")
const SidePanel = preload("res://addons/theme_maker/scenes/side_panel.tscn")
var main_panel_instance
var side_panel_instance
func _enter_tree():
main_panel_instance = MainPanel.instance()
side_panel_instance = SidePanel.instance()
get_editor_interface().get_editor_viewport().add_child(main_panel_instance)
add_control_to_dock(DOCK_SLOT_RIGHT_UR, side_panel_instance)
make_visible(false)
func _exit_tree():
main_panel_instance.queue_free()
side_panel_instance.queue_free()
func _ready():
print("Debug 1")
main_panel_instance.connect("main_button_pressed", side_panel_instance, "_on_main_button_pressed")
side_panel_instance.connect("side_button_pressed", main_panel_instance, "_on_side_button_pressed")
main_panel_instance.emit_signal("main_button_pressed", "Hello 1")
side_panel_instance.emit_signal("side_button_pressed", "Hello 2")
func has_main_screen():
return true
func make_visible(visible):
if visible:
main_panel_instance.show()
else:
main_panel_instance.hide()
func get_plugin_name():
return "Theme Maker"
This is the debug output when activating the plugin
Debug 1
core/object.cpp:1238 - Error calling method from signal 'main_button_pressed': 'Panel(side_panel.gd)::_on_main_button_pressed': Method not found.
core/object.cpp:1238 - Error calling method from signal 'side_button_pressed': 'Panel(main_panel.gd)::_on_side_button_pressed': Method not found.
No debug statements are printed when pressing either button
This is the scene tree for both Side and Main Panels (Same structure, different scenes)
- Panel
-
- Button
-
- Label
I simply don’t know what is going wrong.
It seems like the buttons are not initialized properly or not connected. I tried manually connecting signals as well with no results.
Any help would be much appreciated. Thank you.
In side_panel.gd
, you have a typo while defining your signal callback. I would also prefix underscores to all signal callbacks. Usually, they’re private and don’t need to be shown to the world.
I’d also add a little more detail to the rubber-duck statements. It’s easier to follow.
Kyle Guarco | 2019-08-22 01:28
Thanks. I fixed that typo and made both callbacks private.
Algorithmite | 2019-08-24 04:22
For clarification I expect the starting output to be:
Debug 1
Debug 4
Debug 2
This is the ready function being called in all three scripts.
And then another debug statement whenever a button is pressed.
Algorithmite | 2019-08-24 04:25