Merge pull request #94610 from ajreckof/Fix-Object-encoded-as-id-in-dictionnaries-to-be-represented-as-int-in-the-inspector-
Fix Object encoded as id in dictionaries to be represented as int in the inspector.
This commit is contained in:
commit
23a1104d78
|
@ -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<EncodedObjectAsID>(r_ret)) {
|
||||
r_ret = Object::cast_to<EncodedObjectAsID>(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<EncodedObjectAsID>(r_ret)) {
|
||||
r_ret = Object::cast_to<EncodedObjectAsID>(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.
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue