Skip to content

Commit 84becbe

Browse files
committed
Fix C# exports print errors due to missing ClassDB binding
1 parent 549a595 commit 84becbe

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

bt/tasks/bt_task.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -386,16 +386,21 @@ void BTTask::print_tree(int p_initial_tabs) {
386386
}
387387
}
388388

389-
#ifdef TOOLS_ENABLED
390-
391389
Ref<BehaviorTree> BTTask::editor_get_behavior_tree() {
390+
#ifdef TOOLS_ENABLED
392391
BTTask *task = this;
393392
while (task->data.behavior_tree_id.is_null() && task->get_parent().is_valid()) {
394393
task = task->data.parent;
395394
}
396395
return Object::cast_to<BehaviorTree>(ObjectDB::get_instance(task->data.behavior_tree_id));
396+
#else
397+
ERR_PRINT("BTTask::editor_get_behavior_tree: Not available in release builds.");
398+
return Ref<BehaviorTree>();
399+
#endif
397400
}
398401

402+
#ifdef TOOLS_ENABLED
403+
399404
void BTTask::editor_set_behavior_tree(const Ref<BehaviorTree> &p_bt) {
400405
data.behavior_tree_id = p_bt->get_instance_id();
401406
}
@@ -423,9 +428,7 @@ void BTTask::_bind_methods() {
423428
ClassDB::bind_method(D_METHOD("print_tree", "initial_tabs"), &BTTask::print_tree, Variant(0));
424429
ClassDB::bind_method(D_METHOD("get_task_name"), &BTTask::get_task_name);
425430
ClassDB::bind_method(D_METHOD("abort"), &BTTask::abort);
426-
#ifdef TOOLS_ENABLED
427431
ClassDB::bind_method(D_METHOD("editor_get_behavior_tree"), &BTTask::editor_get_behavior_tree);
428-
#endif // TOOLS_ENABLED
429432

430433
// Properties, setters and getters.
431434
ClassDB::bind_method(D_METHOD("get_agent"), &BTTask::get_agent);

bt/tasks/bt_task.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ class BTTask : public BT {
166166

167167
void print_tree(int p_initial_tabs = 0);
168168

169-
#ifdef TOOLS_ENABLED
170169
Ref<BehaviorTree> editor_get_behavior_tree();
170+
#ifdef TOOLS_ENABLED
171171
void editor_set_behavior_tree(const Ref<BehaviorTree> &p_bt);
172172
#endif
173173

0 commit comments

Comments
 (0)