Merge pull request #70030 from KoBeWi/why_is_tween
Improve empty Tween error message
This commit is contained in:
commit
51f0d723b4
2 changed files with 21 additions and 1 deletions
|
@ -280,7 +280,16 @@ bool Tween::step(double p_delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!started) {
|
if (!started) {
|
||||||
ERR_FAIL_COND_V_MSG(tweeners.is_empty(), false, "Tween started, but has no Tweeners.");
|
if (tweeners.is_empty()) {
|
||||||
|
String tween_id;
|
||||||
|
Node *node = get_bound_node();
|
||||||
|
if (node) {
|
||||||
|
tween_id = vformat("Tween (bound to %s)", node->is_inside_tree() ? (String)node->get_path() : (String)node->get_name());
|
||||||
|
} else {
|
||||||
|
tween_id = to_string();
|
||||||
|
}
|
||||||
|
ERR_FAIL_V_MSG(false, tween_id + ": started with no Tweeners.");
|
||||||
|
}
|
||||||
current_step = 0;
|
current_step = 0;
|
||||||
loops_done = 0;
|
loops_done = 0;
|
||||||
total_time = 0;
|
total_time = 0;
|
||||||
|
@ -393,6 +402,15 @@ Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, d
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String Tween::to_string() {
|
||||||
|
String ret = Object::to_string();
|
||||||
|
Node *node = get_bound_node();
|
||||||
|
if (node) {
|
||||||
|
ret += vformat(" (bound to %s)", node->get_name());
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void Tween::_bind_methods() {
|
void Tween::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("tween_property", "object", "property", "final_val", "duration"), &Tween::tween_property);
|
ClassDB::bind_method(D_METHOD("tween_property", "object", "property", "final_val", "duration"), &Tween::tween_property);
|
||||||
ClassDB::bind_method(D_METHOD("tween_interval", "time"), &Tween::tween_interval);
|
ClassDB::bind_method(D_METHOD("tween_interval", "time"), &Tween::tween_interval);
|
||||||
|
|
|
@ -130,6 +130,8 @@ protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual String to_string() override;
|
||||||
|
|
||||||
Ref<PropertyTweener> tween_property(Object *p_target, NodePath p_property, Variant p_to, double p_duration);
|
Ref<PropertyTweener> tween_property(Object *p_target, NodePath p_property, Variant p_to, double p_duration);
|
||||||
Ref<IntervalTweener> tween_interval(double p_time);
|
Ref<IntervalTweener> tween_interval(double p_time);
|
||||||
Ref<CallbackTweener> tween_callback(Callable p_callback);
|
Ref<CallbackTweener> tween_callback(Callable p_callback);
|
||||||
|
|
Loading…
Add table
Reference in a new issue