Open BehaviorTree in the BT editor when its property is clicked in the inspector

This commit is contained in:
Serhii Snitsaruk 2023-12-18 15:49:20 +01:00
parent e03887cdde
commit 3f61204961
3 changed files with 8 additions and 2 deletions

View File

@ -37,7 +37,6 @@ void BehaviorTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_description"), &BehaviorTree::get_description); 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("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("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("clone"), &BehaviorTree::clone);
ClassDB::bind_method(D_METHOD("instantiate", "p_agent", "p_blackboard"), &BehaviorTree::instantiate); ClassDB::bind_method(D_METHOD("instantiate", "p_agent", "p_blackboard"), &BehaviorTree::instantiate);

View File

@ -42,7 +42,6 @@ public:
} }
Ref<BTTask> get_root_task() const { return root_task; } Ref<BTTask> get_root_task() const { return root_task; }
// void init();
Ref<BehaviorTree> clone() const; Ref<BehaviorTree> clone() const;
Ref<BTTask> instantiate(Node *p_agent, const Ref<Blackboard> &p_blackboard) const; Ref<BTTask> instantiate(Node *p_agent, const Ref<Blackboard> &p_blackboard) const;
}; };

View File

@ -1288,6 +1288,14 @@ void LimboAIEditorPlugin::apply_changes() {
} }
void LimboAIEditorPlugin::_notification(int p_notification) { 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) { void LimboAIEditorPlugin::make_visible(bool p_visible) {