- Edited
hello,
Iam making this plugIn were the user draws on screen... Problem here is i cant keep the node selected. Once i press the node the plugIn the menu showsUp / when i press the editor screen the node gets deselected ?!?
Is there a way to keep the node selected like in the original tileMap node ?
I cant find anything in the manual, or the original tileMap code, that explains a simple node selection like this... Everything is scattered.
The original tileMap node is keeping the node selected on the screen someHow, and the user is able to press the main editor at any time, without deselecting the node... Its just such a simple thing to do, and yet so neglected, that its driving me crazy, to the point of just be done and leave this engine... If it was a complicated thing..ok.. fine... but such a simple thing causing such a mess, like having an ant on the middle of a free way and the A.I. cars are forced to stop... it just seems stupid...
`
@tool
extends EditorPlugin
const editorAddon = preload("res://addons/tiletest/tilePlugTest.tscn");
const tileDrawNode = preload("res://addons/tiletest/tileDrawNode.gd");
const tileDrawIcon = preload("res://addons/tiletest/icon.png");
var dockedCanvas;
var dockedScene;
var subVcont;
var subVport;
var label1;
var label2;
var camTl;
var img;
var Mimg: int = 0;
var MouseOnImage;
var blk;
var blk2;
func _enter_tree():
add_custom_type("TileDraw", "Node2D", tileDrawNode, tileDrawIcon );
dockedScene = editorAddon.instantiate();
add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, dockedScene );
dockedScene.custom_minimum_size = Vector2(10,0);
if not is_instance_valid(dockedScene):
return;
subVcont = dockedScene.get_node("SubViewportContainer");
subVport = dockedScene.get_node("SubViewportContainer/SubViewport");
label1 = dockedScene.get_node("Label");
label2 = dockedScene.get_node("Label2");
img = dockedScene.get_node("SubViewportContainer/SubViewport/Icon");
camTl = dockedScene.get_node("SubViewportContainer/SubViewport/Camera2D");
blk = dockedScene.get_node("Blk");
blk2 = dockedScene.get_node("Blk2");
var editorSel = get_editor_interface().get_selection().get_selected_nodes()
if ( editorSel.has('TileDraw') ):
dockedScene.visible = false;
else:
dockedScene.visible = true;
func _handles(object: Object) -> bool:
return object is tileDrawNode
func _make_visible(visible: bool) -> void:
dockedScene.visible = visible
`
[ edit ] In the function description _make_visible. the manual states:
This function will be called when the editor is requested to become visible. It is used for plugins that edit a specific object type.
Remember that you have to manage the visibility of all your editor controls manually.
There isnt any info about managing the visibility of all your editor controls manually...