0 votes

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

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


    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"

    func add_button():
        var button = Button.new()
        button.margin_left = 150
        button.margin_top = 20
        button.text = "Press Me"
        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.

in Engine by (168 points)

1 Answer

0 votes

Add this to your code:

func _exit_tree():
by (4,077 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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.