From c33b09ed19d3543472a52ffc7c8a017dd92ee228 Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Wed, 19 Mar 2025 14:44:31 +0100 Subject: [PATCH] Fix issue of `AnimationPlayer` hiding bezier editor when re-selecting it Co-authored-by: Kasper Arnklit Frandsen --- editor/animation/animation_track_editor.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/editor/animation/animation_track_editor.cpp b/editor/animation/animation_track_editor.cpp index 340c1f819b8..7f38b66f4fd 100644 --- a/editor/animation/animation_track_editor.cpp +++ b/editor/animation/animation_track_editor.cpp @@ -3934,7 +3934,7 @@ void AnimationTrackEditor::set_animation(const Ref &p_anim, bool p_re marker_edit->set_animation(p_anim, read_only); marker_edit->set_play_position(timeline->get_play_position()); - _cancel_bezier_edit(); + _check_bezier_exist(); _update_tracks(); if (animation.is_valid()) { @@ -3963,7 +3963,14 @@ void AnimationTrackEditor::set_animation(const Ref &p_anim, bool p_re } } - _check_bezier_exist(); + if (bezier_edit->is_visible()) { + for (int i = 0; i < animation->get_track_count(); ++i) { + if (animation->track_get_type(i) == Animation::TrackType::TYPE_BEZIER) { + _bezier_edit(i); + break; + } + } + } } else { hscroll->hide(); edit->set_disabled(true); @@ -3984,10 +3991,12 @@ void AnimationTrackEditor::set_animation(const Ref &p_anim, bool p_re void AnimationTrackEditor::_check_bezier_exist() { bool is_exist = false; - for (int i = 0; i < animation->get_track_count(); i++) { - if (animation->track_get_type(i) == Animation::TrackType::TYPE_BEZIER) { - is_exist = true; - break; + if (animation.is_valid()) { + for (int i = 0; i < animation->get_track_count(); i++) { + if (animation->track_get_type(i) == Animation::TrackType::TYPE_BEZIER) { + is_exist = true; + break; + } } } if (is_exist) {