Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if property exists before tweening #81525

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion scene/animation/tween.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,15 @@ Ref<PropertyTweener> Tween::tween_property(const Object *p_target, const NodePat
CHECK_VALID();

Vector<StringName> property_subnames = p_property.get_as_property_path().get_subnames();
if (!_validate_type_match(p_target->get_indexed(property_subnames), p_to)) {
#ifdef DEBUG_ENABLED
bool prop_valid;
const Variant &prop_value = p_target->get_indexed(property_subnames, &prop_valid);
ERR_FAIL_COND_V_MSG(!prop_valid, nullptr, vformat("The tweened property \"%s\" does not exist in object \"%s\".", p_property, p_target));
#else
const Variant &prop_value = p_target->get_indexed(property_subnames);
#endif

if (!_validate_type_match(prop_value, p_to)) {
return nullptr;
}

Expand Down