From fed2879463419583ccaf375d7cd44cff56fc69bf Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Mon, 29 Aug 2022 14:20:33 +0800 Subject: [PATCH] Improve documentation for `get_animation()` --- doc/classes/AnimationPlayer.xml | 2 +- scene/animation/animation_player.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml index a3752e9abc8..dd2caa92532 100644 --- a/doc/classes/AnimationPlayer.xml +++ b/doc/classes/AnimationPlayer.xml @@ -67,7 +67,7 @@ - Returns the [Animation] with key [code]name[/code] or [code]null[/code] if not found. + Returns the [Animation] with the key [code]name[/code]. 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 7c0b6e0441b..44d568407d8 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1052,13 +1052,15 @@ void AnimationPlayer::rename_animation(const StringName &p_name, const StringNam bool AnimationPlayer::has_animation(const StringName &p_name) const { return animation_set.has(p_name); } + Ref AnimationPlayer::get_animation(const StringName &p_name) const { - ERR_FAIL_COND_V(!animation_set.has(p_name), Ref()); + 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]; return data.animation; } + void AnimationPlayer::get_animation_list(List *p_animations) const { List anims;