From cf74b3674031f30f9f28fd0d673f2d40fe246075 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 22 Apr 2022 20:37:28 +0200 Subject: [PATCH] Fix RESET animation not being created --- editor/animation_track_editor.cpp | 12 ++++++++++-- scene/animation/animation_tree.cpp | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 685dde4d988..7554d97aeff 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -4033,12 +4033,20 @@ Ref AnimationTrackEditor::_create_and_get_reset_animation() { if (player->has_animation(SceneStringNames::get_singleton()->RESET)) { return player->get_animation(SceneStringNames::get_singleton()->RESET); } else { + Ref al; + if (!player->has_animation_library("")) { + al.instantiate(); + player->add_animation_library("", al); + } else { + al = player->get_animation_library(""); + } + Ref reset_anim; reset_anim.instantiate(); reset_anim->set_length(ANIM_MIN_LENGTH); - undo_redo->add_do_method(player, "add_animation", SceneStringNames::get_singleton()->RESET, reset_anim); + undo_redo->add_do_method(al.ptr(), "add_animation", SceneStringNames::get_singleton()->RESET, reset_anim); undo_redo->add_do_method(AnimationPlayerEditor::get_singleton(), "_animation_player_changed", player); - undo_redo->add_undo_method(player, "remove_animation", SceneStringNames::get_singleton()->RESET); + undo_redo->add_undo_method(al.ptr(), "remove_animation", SceneStringNames::get_singleton()->RESET); undo_redo->add_undo_method(AnimationPlayerEditor::get_singleton(), "_animation_player_changed", player); return reset_anim; } diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 0996eb9f9f6..8d21ec80781 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -541,9 +541,9 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { player->get_animation_list(&sname); Ref reset_anim; - bool has_reset_anim = player->has_animation("RESET"); + bool has_reset_anim = player->has_animation(SceneStringNames::get_singleton()->RESET); if (has_reset_anim) { - reset_anim = player->get_animation("RESET"); + reset_anim = player->get_animation(SceneStringNames::get_singleton()->RESET); } for (const StringName &E : sname) { Ref anim = player->get_animation(E);