X Tutup
Skip to content

Validate Resource type when pasting property#112386

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
KoBeWi:editor_resource_hacker
Jan 5, 2026
Merged

Validate Resource type when pasting property#112386
Repiteo merged 1 commit intogodotengine:masterfrom
KoBeWi:editor_resource_hacker

Conversation

@KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Nov 4, 2025

Fixes #112347

When you paste a property value, the inspector will just emit that property has changed with the new value, without doing any validation. It works with built-in properties, because when you try to e.g. assign Object to float or Texture2D to Image, the engine will cast it to the new value and assign whatever remains after casting (so e.g. you can paste Resource as bool and it will assign true).

It's a bit different for script properties. If the script isn't @tool, they are assigned to PlaceholderScriptInstance, which has no information about the properties. Whatever you set just goes in. After the value is pasted, the EditorProperty will update itself based on the value. In most cases the value will correct itself, e.g. you can't assign Node to EditorPropertyInt, because it just can't accept/display that value.

Then there is EditorPropertyResource. After #84446 the validation of the value assigned to the object does not happen, so as long as it's any Resource, the property will accept it. This, coupled with what I explained above, is the source of the bug. I opted to fix it at pasting operation.

@KoBeWi KoBeWi added this to the 4.6 milestone Nov 4, 2025
@KoBeWi KoBeWi requested a review from a team November 4, 2025 15:22
custom_class = EditorNode::get_singleton()->get_object_custom_type_name(p_resource->get_script());
}
const String class_str = (custom_class.is_empty() ? p_resource->get_class() : vformat("%s (%s)", custom_class, p_resource->get_class()));
ERR_FAIL_MSG(vformat("Failed to set a resource of the type '%s' because this EditorResourcePicker only accepts '%s' and its derivatives.", class_str, base_type));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be ERR_FAIL_EDMSG to show in the toaster?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh I'm not sure when this error can appear normally. The paste operation does not trigger it, and I don't think you can assign wrong resource any other way using the inspector.

@akien-mga
Copy link
Member

Needs rebase.

@KoBeWi KoBeWi force-pushed the editor_resource_hacker branch from 4fdc5b3 to c23a224 Compare January 5, 2026 17:24
@Repiteo Repiteo merged commit 95e78ba into godotengine:master Jan 5, 2026
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jan 5, 2026

Thanks!

@KoBeWi KoBeWi deleted the editor_resource_hacker branch January 5, 2026 18:18
rivie13 pushed a commit to rivie13/Phoenix-Agentic-Engine that referenced this pull request Feb 16, 2026
Validate Resource type when pasting property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible to copy-paste a Resource into an exported property field of different Resource type

3 participants

X Tutup