Skip to content

Commit 8798387

Browse files
committed
Improve identification of edits on property Object->script
Narrows down the criteria to determine if the property being edited with the `EditorResourcePicker` is actually the `Object->script` property.
1 parent 89f32c6 commit 8798387

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

editor/inspector/editor_resource_picker.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,19 @@ bool EditorResourcePicker::_is_type_valid(const String &p_type_name, const HashS
778778
}
779779

780780
bool EditorResourcePicker::_is_custom_type_script() const {
781-
Ref<Script> resource_as_script = edited_resource;
781+
EditorProperty *editor_property = Object::cast_to<EditorProperty>(get_parent());
782+
if (!editor_property) {
783+
return false;
784+
}
782785

783-
if (resource_as_script.is_valid() && resource_owner && resource_owner->has_meta(SceneStringName(_custom_type_script))) {
784-
return true;
786+
// Check if the property being edited is 'script'.
787+
if (editor_property->get_edited_property() == CoreStringName(script)) {
788+
// If there's currently a valid script assigned and the owning Node/Resource also has a custom type script assigned, then
789+
// the currently assigned script is either the custom type script itself or an extension of it.
790+
Ref<Script> resource_as_script = edited_resource;
791+
if (resource_as_script.is_valid() && resource_owner && resource_owner->has_meta(SceneStringName(_custom_type_script))) {
792+
return true;
793+
}
785794
}
786795

787796
return false;

0 commit comments

Comments
 (0)