From 360c71c3f63bce8419df35b3bac358979742b8a7 Mon Sep 17 00:00:00 2001 From: kobewi Date: Wed, 1 Feb 2023 00:50:34 +0100 Subject: Prevent wrong unedit when clicking editor viewport --- editor/editor_node.cpp | 7 +++++++ editor/editor_node.h | 1 + editor/scene_tree_dock.cpp | 9 ++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'editor') diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 0405749147..fe62d9dda0 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2136,6 +2136,13 @@ void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) { } } +void EditorNode::push_node_item(Node *p_node) { + if (p_node || Object::cast_to(InspectorDock::get_inspector_singleton()->get_edited_object())) { + // Don't push null if the currently edited object is not a Node. + push_item(p_node); + } +} + void EditorNode::push_item(Object *p_object, const String &p_property, bool p_inspector_only) { if (!p_object) { InspectorDock::get_inspector_singleton()->edit(nullptr); diff --git a/editor/editor_node.h b/editor/editor_node.h index 3967f64c6b..914dab0254 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -798,6 +798,7 @@ public: void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false); void edit_item(Object *p_object, Object *p_editing_owner); + void push_node_item(Node *p_node); void hide_unused_editors(const Object *p_editing_owner = nullptr); void select_editor_by_name(const String &p_name); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 86e77fbbbe..d8f1d92e44 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1427,7 +1427,14 @@ void SceneTreeDock::_script_open_request(const Ref