From 385a5b44aa32319bd918c19ec9c8f375444f4802 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Mon, 29 Aug 2022 14:18:01 +0800 Subject: [PATCH] Improve documentation for `get_animation()` --- doc/classes/AnimationLibrary.xml | 2 +- doc/classes/AnimationPlayer.xml | 2 +- scene/animation/animation_player.cpp | 2 +- scene/resources/animation_library.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/classes/AnimationLibrary.xml b/doc/classes/AnimationLibrary.xml index fbbf9a3be42..75fe393dbbe 100644 --- a/doc/classes/AnimationLibrary.xml +++ b/doc/classes/AnimationLibrary.xml @@ -22,7 +22,7 @@ - Returns the [Animation] with the key [param name], or [code]null[/code] if none is found. + Returns the [Animation] with the key [param name]. If the animation does not exist, [code]null[/code] is returned and an error is logged. diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml index d771206cc2d..710dc55a4b3 100644 --- a/doc/classes/AnimationPlayer.xml +++ b/doc/classes/AnimationPlayer.xml @@ -75,7 +75,7 @@ - Returns the [Animation] with key [param name] or [code]null[/code] if not found. + Returns the [Animation] with the key [param name]. If the animation does not exist, [code]null[/code] is returned and an error is logged. diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 0e2598cbc7c..073f61bfdd2 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1501,7 +1501,7 @@ bool AnimationPlayer::has_animation(const StringName &p_name) const { } Ref AnimationPlayer::get_animation(const StringName &p_name) const { - ERR_FAIL_COND_V_MSG(!animation_set.has(p_name), Ref(), vformat("Animation not found: %s.", p_name)); + ERR_FAIL_COND_V_MSG(!animation_set.has(p_name), Ref(), vformat("Animation not found: \"%s\".", p_name)); const AnimationData &data = animation_set[p_name]; diff --git a/scene/resources/animation_library.cpp b/scene/resources/animation_library.cpp index 5f725b2fbe8..427d4185515 100644 --- a/scene/resources/animation_library.cpp +++ b/scene/resources/animation_library.cpp @@ -85,7 +85,7 @@ bool AnimationLibrary::has_animation(const StringName &p_name) const { } Ref AnimationLibrary::get_animation(const StringName &p_name) const { - ERR_FAIL_COND_V(!animations.has(p_name), Ref()); + ERR_FAIL_COND_V_MSG(!animations.has(p_name), Ref(), vformat("Animation not found: \"%s\".", p_name)); return animations[p_name]; }