From 3f6120496177f6a43b73c4a95166ef7b1f9e0e15 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Mon, 18 Dec 2023 15:49:20 +0100 Subject: [PATCH] Open BehaviorTree in the BT editor when its property is clicked in the inspector --- bt/behavior_tree.cpp | 1 - bt/behavior_tree.h | 1 - editor/limbo_ai_editor_plugin.cpp | 8 ++++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bt/behavior_tree.cpp b/bt/behavior_tree.cpp index f4e7cd44..b761843e 100644 --- a/bt/behavior_tree.cpp +++ b/bt/behavior_tree.cpp @@ -37,7 +37,6 @@ void BehaviorTree::_bind_methods() { ClassDB::bind_method(D_METHOD("get_description"), &BehaviorTree::get_description); ClassDB::bind_method(D_METHOD("set_root_task", "p_value"), &BehaviorTree::set_root_task); ClassDB::bind_method(D_METHOD("get_root_task"), &BehaviorTree::get_root_task); - // ClassDB::bind_method(D_METHOD("init"), &BehaviorTree::init); ClassDB::bind_method(D_METHOD("clone"), &BehaviorTree::clone); ClassDB::bind_method(D_METHOD("instantiate", "p_agent", "p_blackboard"), &BehaviorTree::instantiate); diff --git a/bt/behavior_tree.h b/bt/behavior_tree.h index f8582b04..cb35c968 100644 --- a/bt/behavior_tree.h +++ b/bt/behavior_tree.h @@ -42,7 +42,6 @@ class BehaviorTree : public Resource { } Ref get_root_task() const { return root_task; } - // void init(); Ref clone() const; Ref instantiate(Node *p_agent, const Ref &p_blackboard) const; }; diff --git a/editor/limbo_ai_editor_plugin.cpp b/editor/limbo_ai_editor_plugin.cpp index 211557e9..8f8a6cea 100644 --- a/editor/limbo_ai_editor_plugin.cpp +++ b/editor/limbo_ai_editor_plugin.cpp @@ -1288,6 +1288,14 @@ void LimboAIEditorPlugin::apply_changes() { } void LimboAIEditorPlugin::_notification(int p_notification) { + if (p_notification == NOTIFICATION_ENTER_TREE) { + // Add BehaviorTree to the list of resources that should open in a new inspector. + PackedStringArray open_in_new_inspector = EDITOR_GET("interface/inspector/resources_to_open_in_new_inspector"); + if (!open_in_new_inspector.has("BehaviorTree")) { + open_in_new_inspector.push_back("BehaviorTree"); + EditorSettings::get_singleton()->set_setting("interface/inspector/resources_to_open_in_new_inspector", open_in_new_inspector); + } + } } void LimboAIEditorPlugin::make_visible(bool p_visible) {