0 votes

I have been playing around with editorplugin side of things. To be honest I am struggling
anyway I have the following code

tool
extends EditorPlugin

var a_panel = preload("res://addons/add_bottom_menu/bottom_test.tscn")
var a_new_control := Control.new()

    func _ready():

        #a_new_control = a_panel.instance()
        add_control_to_bottom_panel(a_new_control,"My Plugin")

        var editor_viewport = get_editor_interface().get_editor_viewport()
        yield(get_tree(), 'idle_frame')
        a_new_control.rect_min_size.y = editor_viewport.rect_size.y * 0.35

        add_label()
        add_button()



    func add_label():
        var a_label = Label.new()
        a_label.name = "Label"
        a_label.margin_left = 20
        a_label.margin_top = 20
        a_label.text = "Test"
        a_new_control.add_child(a_label)

    func add_button():
        var button = Button.new()
        button.margin_left = 150
        button.margin_top = 20
        button.text = "Press Me"
        a_new_control.add_child(button)
        button.connect("button_down" ,self,"on_btn_toggled")


    func on_btn_toggled():
        a_new_control.get_node("Label").text = "Clicked"

The code itself works except whenever I made changes to the script I need to de-activate plugin and the reactivate it. And instead of overwrting whatever was already existing at the bottom menu, it would add another one . I am not sure how to remove existing bottom menu item when I de-activate it.

asked Jan 10 in Engine by lowpolygon (166 points)

1 Answer

0 votes

Add this to your code:

func _exit_tree():
    a_new_control.queue_free()
answered Jan 10 by Dlean Jeans (3,873 points)

Sorry, I am not sure what I did wrong. But It is not working.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.