Skip to content

Commit

Permalink
Improve documentation for get_animation()
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyqiu committed Aug 29, 2022
1 parent 47da910 commit fed2879
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/classes/AnimationPlayer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<return type="Animation" />
<argument index="0" name="name" type="String" />
<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>
</method>
<method name="get_animation_list" qualifiers="const">
Expand Down
4 changes: 3 additions & 1 deletion scene/animation/animation_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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];

return data.animation;
}

void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const {
List<String> anims;

Expand Down

0 comments on commit fed2879

Please sign in to comment.