Merge pull request #65020 from timothyqiu/anim-docs-null-3.x

[3.x] Improve documentation for `get_animation()`
This commit is contained in:
Rémi Verschelde 2022-08-29 09:50:35 +02:00 committed by GitHub
commit ea15422d9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -67,7 +67,7 @@
<return type="Animation" /> <return type="Animation" />
<argument index="0" name="name" type="String" /> <argument index="0" name="name" type="String" />
<description> <description>
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.
</description> </description>
</method> </method>
<method name="get_animation_list" qualifiers="const"> <method name="get_animation_list" qualifiers="const">

View File

@ -1052,13 +1052,15 @@ void AnimationPlayer::rename_animation(const StringName &p_name, const StringNam
bool AnimationPlayer::has_animation(const StringName &p_name) const { bool AnimationPlayer::has_animation(const StringName &p_name) const {
return animation_set.has(p_name); return animation_set.has(p_name);
} }
Ref<Animation> AnimationPlayer::get_animation(const StringName &p_name) const { Ref<Animation> AnimationPlayer::get_animation(const StringName &p_name) const {
ERR_FAIL_COND_V(!animation_set.has(p_name), Ref<Animation>()); ERR_FAIL_COND_V_MSG(!animation_set.has(p_name), Ref<Animation>(), vformat("Animation not found: \"%s\".", p_name));
const AnimationData &data = animation_set[p_name]; const AnimationData &data = animation_set[p_name];
return data.animation; return data.animation;
} }
void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const { void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const {
List<String> anims; List<String> anims;