From ad821c4514d5d1992e2c89c67730f80e122921ff Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Tue, 6 Aug 2024 18:17:55 +0200 Subject: [PATCH] Fix C# exports print errors due to missing ClassDB binding --- bt/tasks/bt_task.cpp | 11 +++++++---- bt/tasks/bt_task.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bt/tasks/bt_task.cpp b/bt/tasks/bt_task.cpp index 818999b..b4526ab 100644 --- a/bt/tasks/bt_task.cpp +++ b/bt/tasks/bt_task.cpp @@ -377,16 +377,21 @@ void BTTask::print_tree(int p_initial_tabs) { } } -#ifdef TOOLS_ENABLED - Ref BTTask::editor_get_behavior_tree() { +#ifdef TOOLS_ENABLED BTTask *task = this; while (task->data.behavior_tree_id.is_null() && task->get_parent().is_valid()) { task = task->data.parent; } return Object::cast_to(ObjectDB::get_instance(task->data.behavior_tree_id)); +#else + ERR_PRINT("BTTask::editor_get_behavior_tree: Not available in release builds."); + return Ref(); +#endif } +#ifdef TOOLS_ENABLED + void BTTask::editor_set_behavior_tree(const Ref &p_bt) { data.behavior_tree_id = p_bt->get_instance_id(); } @@ -414,9 +419,7 @@ void BTTask::_bind_methods() { ClassDB::bind_method(D_METHOD("print_tree", "initial_tabs"), &BTTask::print_tree, Variant(0)); ClassDB::bind_method(D_METHOD("get_task_name"), &BTTask::get_task_name); ClassDB::bind_method(D_METHOD("abort"), &BTTask::abort); -#ifdef TOOLS_ENABLED ClassDB::bind_method(D_METHOD("editor_get_behavior_tree"), &BTTask::editor_get_behavior_tree); -#endif // TOOLS_ENABLED // Properties, setters and getters. ClassDB::bind_method(D_METHOD("get_agent"), &BTTask::get_agent); diff --git a/bt/tasks/bt_task.h b/bt/tasks/bt_task.h index b571c27..37e9449 100644 --- a/bt/tasks/bt_task.h +++ b/bt/tasks/bt_task.h @@ -167,8 +167,8 @@ public: void print_tree(int p_initial_tabs = 0); -#ifdef TOOLS_ENABLED Ref editor_get_behavior_tree(); +#ifdef TOOLS_ENABLED void editor_set_behavior_tree(const Ref &p_bt); #endif