summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-05-29 22:14:03 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-05-29 22:14:03 +0200
commita8cc65f54f6d91c79778c7157b313873ec0e05ec (patch)
treecce60b50e0422f02fc91d13f1add6d1e55d5f77c /editor
parent5f572561c5b411b1ff65b6266ceadbbe23d20dce (diff)
parent18cdb3c0d78bf9976b7179bbbf318ccf3d8fe266 (diff)
downloadredot-engine-a8cc65f54f6d91c79778c7157b313873ec0e05ec.tar.gz
Merge pull request #92495 from matheusmdx/fix-animation-player-error
Fix error after create a new animation in an empty AnimationPlayer
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index ccf5b1d04f..1cf11f2a43 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -547,13 +547,18 @@ void AnimationPlayerEditor::_animation_name_edited() {
} break;
case TOOL_NEW_ANIM: {
- String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> current_anim = player->get_animation(current);
Ref<Animation> new_anim = Ref<Animation>(memnew(Animation));
new_anim->set_name(new_name);
- if (current_anim.is_valid()) {
- new_anim->set_step(current_anim->get_step());
+
+ if (animation->get_item_count() > 0) {
+ String current = animation->get_item_text(animation->get_selected());
+ Ref<Animation> current_anim = player->get_animation(current);
+
+ if (current_anim.is_valid()) {
+ new_anim->set_step(current_anim->get_step());
+ }
}
+
String library_name;
Ref<AnimationLibrary> al;
library_name = library->get_item_metadata(library->get_selected());