Skip to content

Commit c9b3896

Browse files
committed
Fix edit resource on inspector when inside array or dictionary
refactor Fix dictionary
1 parent 60b7b8b commit c9b3896

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

editor/inspector/editor_properties_array_dict.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ void EditorPropertyArray::_object_id_selected(const StringName &p_property, Obje
301301
emit_signal(SNAME("object_id_selected"), p_property, p_id);
302302
}
303303

304+
void EditorPropertyArray::_resource_selected(const String &p_path, Ref<Resource> p_resource) {
305+
emit_signal(SNAME("resource_selected"), get_edited_property(), p_resource);
306+
}
307+
304308
void EditorPropertyArray::_create_new_property_slot() {
305309
int idx = slots.size();
306310
HBoxContainer *hbox = memnew(HBoxContainer);
@@ -511,6 +515,9 @@ void EditorPropertyArray::update_property() {
511515
new_prop->set_use_folding(is_using_folding());
512516
new_prop->connect(SNAME("property_changed"), callable_mp(this, &EditorPropertyArray::_property_changed));
513517
new_prop->connect(SNAME("object_id_selected"), callable_mp(this, &EditorPropertyArray::_object_id_selected));
518+
if (value_type == Variant::OBJECT) {
519+
new_prop->connect("resource_selected", callable_mp(this, &EditorPropertyArray::_resource_selected), CONNECT_DEFERRED);
520+
}
514521
new_prop->set_h_size_flags(SIZE_EXPAND_FILL);
515522
new_prop->set_read_only(is_read_only());
516523
slot.prop->add_sibling(new_prop, false);
@@ -1393,6 +1400,9 @@ void EditorPropertyDictionary::update_property() {
13931400
new_prop->set_use_folding(is_using_folding());
13941401
new_prop->connect(SNAME("property_changed"), callable_mp(this, &EditorPropertyDictionary::_property_changed));
13951402
new_prop->connect(SNAME("object_id_selected"), callable_mp(this, &EditorPropertyDictionary::_object_id_selected));
1403+
if (value_type == Variant::OBJECT) {
1404+
new_prop->connect("resource_selected", callable_mp(this, &EditorPropertyDictionary::_resource_selected), CONNECT_DEFERRED);
1405+
}
13961406
new_prop->set_h_size_flags(SIZE_EXPAND_FILL);
13971407
if (slot.index != EditorPropertyDictionaryObject::NEW_KEY_INDEX && slot.index != EditorPropertyDictionaryObject::NEW_VALUE_INDEX) {
13981408
new_prop->set_draw_label(false);
@@ -1443,6 +1453,10 @@ void EditorPropertyDictionary::_object_id_selected(const StringName &p_property,
14431453
emit_signal(SNAME("object_id_selected"), p_property, p_id);
14441454
}
14451455

1456+
void EditorPropertyDictionary::_resource_selected(const String &p_path, Ref<Resource> p_resource) {
1457+
emit_signal(SNAME("resource_selected"), get_edited_property(), p_resource);
1458+
}
1459+
14461460
void EditorPropertyDictionary::_notification(int p_what) {
14471461
switch (p_what) {
14481462
case NOTIFICATION_THEME_CHANGED: {

editor/inspector/editor_properties_array_dict.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ class EditorPropertyArray : public EditorProperty {
139139
void _reorder_button_up();
140140
void _create_new_property_slot();
141141

142+
void _resource_selected(const String &p_path, Ref<Resource> p_resource);
143+
142144
Node *get_base_node();
143145

144146
protected:
@@ -243,6 +245,7 @@ class EditorPropertyDictionary : public EditorProperty {
243245
void _page_changed(int p_page);
244246
void _edit_pressed();
245247
void _property_changed(const String &p_property, Variant p_value, const String &p_name = "", bool p_changing = false);
248+
void _resource_selected(const String &p_path, Ref<Resource> p_resource);
246249
void _change_type(Object *p_button, int p_slot_index);
247250
void _change_type_menu(int p_index);
248251

0 commit comments

Comments
 (0)