From f72c91e0b17e6070051dec8fe4b0425dbb02c6d6 Mon Sep 17 00:00:00 2001 From: kobewi Date: Wed, 7 Apr 2021 22:08:41 +0200 Subject: [PATCH] Expose edit_node() for editor plugins (cherry picked from commit 72014a7a2edd3664f146965c529c5b167e3a2a26) --- doc/classes/EditorInterface.xml | 9 +++++++++ doc/classes/EditorSelection.xml | 1 + editor/editor_plugin.cpp | 5 +++++ editor/editor_plugin.h | 1 + 4 files changed, 16 insertions(+) diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 2ec61389b4f..1c8ca041db0 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -10,6 +10,15 @@ + + + + + + + Edits the given [Node]. The node will be also selected if it's inside the scene tree. + + diff --git a/doc/classes/EditorSelection.xml b/doc/classes/EditorSelection.xml index 9786daf4f0b..48a146034ca 100644 --- a/doc/classes/EditorSelection.xml +++ b/doc/classes/EditorSelection.xml @@ -17,6 +17,7 @@ Adds a node to the selection. + [b]Note:[/b] The newly selected node will not be automatically edited in the inspector. If you want to edit a node, use [method EditorInterface.edit_node]. diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index e3c7fced2de..f35805c8ea2 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -166,6 +166,10 @@ void EditorInterface::edit_resource(const Ref &p_resource) { EditorNode::get_singleton()->edit_resource(p_resource); } +void EditorInterface::edit_node(Node *p_node) { + EditorNode::get_singleton()->edit_node(p_node); +} + void EditorInterface::open_scene_from_path(const String &scene_path) { if (EditorNode::get_singleton()->is_changing_scene()) { @@ -322,6 +326,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("get_base_control"), &EditorInterface::get_base_control); ClassDB::bind_method(D_METHOD("get_editor_scale"), &EditorInterface::get_editor_scale); ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorInterface::edit_resource); + ClassDB::bind_method(D_METHOD("edit_node", "node"), &EditorInterface::edit_node); ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorInterface::open_scene_from_path); ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path); ClassDB::bind_method(D_METHOD("play_main_scene"), &EditorInterface::play_main_scene); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 5870fc12bea..c82af4a2653 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -70,6 +70,7 @@ public: Control *get_editor_viewport(); void edit_resource(const Ref &p_resource); + void edit_node(Node *p_node); void open_scene_from_path(const String &scene_path); void reload_scene_from_path(const String &scene_path);