From f46e94d460b8a355acb266dbd20a5483dc967498 Mon Sep 17 00:00:00 2001 From: ajreckof Date: Mon, 22 Jul 2024 09:53:03 +0200 Subject: [PATCH] Fix Object encoded as id in dictionnaries to be represented as int in the inspector. --- editor/editor_properties_array_dict.cpp | 17 ++++++++++++----- editor/editor_properties_array_dict.h | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 633f6abad93..c6fb323f1a4 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -124,6 +124,16 @@ bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Varian } bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_ret) const { + if (!get_by_property_name(p_name, r_ret)) { + return false; + } + if (r_ret.get_type() == Variant::OBJECT && Object::cast_to(r_ret)) { + r_ret = Object::cast_to(r_ret)->get_object_id(); + } + return true; +} + +bool EditorPropertyDictionaryObject::get_by_property_name(const String &p_name, Variant &r_ret) const { String name = p_name; if (name == "new_item_key") { @@ -140,10 +150,6 @@ bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_r int index = name.get_slicec('/', 1).to_int(); Variant key = dict.get_key_at_index(index); r_ret = dict[key]; - if (r_ret.get_type() == Variant::OBJECT && Object::cast_to(r_ret)) { - r_ret = Object::cast_to(r_ret)->get_object_id(); - } - return true; } @@ -1050,7 +1056,8 @@ void EditorPropertyDictionary::update_property() { if (!slot_visible) { continue; } - Variant value = object->get(slot.prop_name); + Variant value; + object->get_by_property_name(slot.prop_name, value); Variant::Type value_type = value.get_type(); // Check if the editor property needs to be updated. diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index 267cb1e86d1..acde7667549 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -77,6 +77,7 @@ public: NEW_VALUE_INDEX, }; + bool get_by_property_name(const String &p_name, Variant &r_ret) const; void set_dict(const Dictionary &p_dict); Dictionary get_dict();