hello,
i have an editor plugin. It instances a scene and puts in a left dock,
i made a new sprite node in the scene that draws a square that follows the mouse coords,
problem is... now its being drawn on 2 places, instead of the main screen...

( plugin script )

@tool
extends EditorPlugin
const editorAddon = preload("res://plugIN/addon.tscn");

func _enter_tree():
	dockedScene = editorAddon.instantiate();
	add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, dockedScene );

( canvas script )

@tool
extends Sprite2D

func _enter_tree():
	scene_root = get_tree().get_edited_scene_root()
	mGpos = scene_root.get_local_mouse_position()

func _draw():
	draw_rect(Rect2(mGpos.x, mGpos.y, 32, 32 ), Color.YELLOW, true );
	draw_string(font,Vector2(5, 570),"mPOS: "+ str( mGpos ), HORIZONTAL_ALIGNMENT_LEFT, -1, 12, Color.WHITE );

It gets wrost when i create a new scene, the drawing only shows on the dock

Is there a way to solve this problem, or place were i can see how plugIns work, i cant find any info about it, and some commands used in plug ins dont even show on the manual...
Ive tried multiple things nothing seems to work... // instancianting 2 scenes 1 for drawing other for the dock, doesnt work
func _forward_canvas_draw_over_viewport(viewport_control) doesnt do anyhing....

I wonder, if you remove the tool attribute, does that fixes it? If it's an editor plugin then I don't think the tool attribute should be needed. To be fair tho, it's been a while since I last tinkered with editor plugins and that was back in godot 3.

    Megalomaniak thanks,
    i dont know... its very hard to understand. If i remove @tool, it doesnt draw in the editor anymore.

    I think i may have solved the problem...
    In the plgin main script

    @tool
    extends EditorPlugin
    
    const editorAddon = preload("res://plugIN/addon.tscn");
    const canv = preload("res://plugIN/canvas_a.tscn");
    
    var mainPanel;
    var dockedScene;
    
    
    func _enter_tree():
    	dockedScene = editorAddon.instantiate();
    	add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, dockedScene );
    	
    	mainPanel = canv.instantiate();
    	get_tree().get_edited_scene_root().add_child(mainPanel)

    (canvas_a.tscn)

    @tool
    extends Sprite2D
    var mGpos;
    
    func _ready():
    	pass # Replace with function body.
    
    func _process(delta):
    	mGpos = get_local_mouse_position()
    	queue_redraw();
    	pass
    
    func _draw():
    	draw_rect(Rect2(mGpos.x, mGpos.y, 32, 32 ), Color.WHITE, true );
    	pass;

    I dont understand... its a very simple concept, but i had to reload current project, autoLoad and unload the plugIn script.
    it even works with a new empty scene, but sometimes it works other times it doesnt,,,
    In the log:

    res://plugIN/canvas.gd:11 - Attempt to call function 'get_local_mouse_position' in base 'null instance' on a null instance.
    res://plugIN/pluginLoader.gd:34 - Cannot call method 'add_child' on a null value.
    Control was not in dock.

    Control was not in dock.
    res://plugIN/canvas_a.gd:20 - Invalid get index 'x' (on base: 'Nil').
    Toggle Autoload Globals
    Control was not in dock.
    res://plugIN/canvas_a.gd:20 - Invalid get index 'x' (on base: 'Nil').

    this works by pressing the enable ON/OFF in autoLoad,
    Its telling that the nodes are null, it start working by creating a new node, even if the loaded scenes addon.tscn and canvas_a.tscn already have nodes in them... very dificult to understand wth is going on in here...

    Megalomaniak

    I wonder, if you remove the tool attribute, does that fixes it?

    you re right it worked

    before
    @tool
    extends Sprite2D

    after
    extends Sprite2D

    Now its only drawing in the editor tree, and i dont have to create a new scene and instantied it... thanks 😃 😃 😃

      jonSS sory all wrong removing @tool doesnt work