Skip to content

Commit a8cc65f

Browse files
committed
Merge pull request #92495 from matheusmdx/fix-animation-player-error
Fix error after create a new animation in an empty AnimationPlayer
2 parents 5f57256 + 18cdb3c commit a8cc65f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

editor/plugins/animation_player_editor_plugin.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,18 @@ void AnimationPlayerEditor::_animation_name_edited() {
547547
} break;
548548

549549
case TOOL_NEW_ANIM: {
550-
String current = animation->get_item_text(animation->get_selected());
551-
Ref<Animation> current_anim = player->get_animation(current);
552550
Ref<Animation> new_anim = Ref<Animation>(memnew(Animation));
553551
new_anim->set_name(new_name);
554-
if (current_anim.is_valid()) {
555-
new_anim->set_step(current_anim->get_step());
552+
553+
if (animation->get_item_count() > 0) {
554+
String current = animation->get_item_text(animation->get_selected());
555+
Ref<Animation> current_anim = player->get_animation(current);
556+
557+
if (current_anim.is_valid()) {
558+
new_anim->set_step(current_anim->get_step());
559+
}
556560
}
561+
557562
String library_name;
558563
Ref<AnimationLibrary> al;
559564
library_name = library->get_item_metadata(library->get_selected());

0 commit comments

Comments
 (0)