From 59b2f4af3c201915c8c650dbfdc51ca95cd60c87 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Wed, 8 Nov 2023 14:23:02 +0100 Subject: [PATCH] Fix: Resetting BBVariant value sets it to NIL --- blackboard/bb_param/bb_param.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/blackboard/bb_param/bb_param.cpp b/blackboard/bb_param/bb_param.cpp index 9cf8168..a674111 100644 --- a/blackboard/bb_param/bb_param.cpp +++ b/blackboard/bb_param/bb_param.cpp @@ -18,6 +18,7 @@ #include "core/object/class_db.h" #include "core/object/object.h" #include "core/variant/variant.h" +#include "core/variant/variant_utility.h" VARIANT_ENUM_CAST(BBParam::ValueSource); @@ -33,7 +34,13 @@ Variant BBParam::get_saved_value() { } void BBParam::set_saved_value(Variant p_value) { - saved_value = p_value; + if (p_value.get_type() == get_type()) { + saved_value = p_value; + } else if (p_value.get_type() == Variant::NIL) { + _assign_default_value(); + } else { + saved_value = VariantUtilityFunctions::type_convert(p_value, get_type()); + } _update_name(); emit_changed(); }