diff options
author | SaracenOne <SaracenOne@gmail.com> | 2022-05-05 04:53:47 +0100 |
---|---|---|
committer | Lyuma <xn.lyuma@gmail.com> | 2022-09-16 14:04:24 -0700 |
commit | 6a8fbf3d256b141442320f0a5e67654257622c60 (patch) | |
tree | a263ac94c204e0ec17bbe8a8b1afcdc694ecc506 /editor/plugins/animation_player_editor_plugin.cpp | |
parent | 57bdddce02370af3d13e6edc583afdc17264147d (diff) |
Fix animation change callbacks
Diffstat (limited to 'editor/plugins/animation_player_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/animation_player_editor_plugin.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 5406aada09..ed1fe9ea58 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -720,7 +720,18 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) { if (p_state.has("player")) { Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]); if (Object::cast_to<AnimationPlayer>(n) && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) { + if (player) { + if (player->is_connected("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) { + player->disconnect("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated)); + } + } player = Object::cast_to<AnimationPlayer>(n); + if (player) { + if (!player->is_connected("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) { + player->connect("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated)); + } + } + _update_player(); EditorNode::get_singleton()->make_bottom_panel_item_visible(this); set_process(true); @@ -977,9 +988,18 @@ void AnimationPlayerEditor::edit(AnimationPlayer *p_player) { if (player && pin->is_pressed()) { return; // Ignore, pinned. } + + if (player) { + if (player->is_connected("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) { + player->disconnect("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated)); + } + } player = p_player; if (player) { + if (!player->is_connected("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) { + player->connect("animation_libraries_updated", callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated)); + } _update_player(); if (onion.enabled) { @@ -1146,6 +1166,10 @@ void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) { } } +void AnimationPlayerEditor::_animation_libraries_updated() { + _animation_player_changed(player); +} + void AnimationPlayerEditor::_list_changed() { if (is_visible_in_tree()) { _update_player(); @@ -1540,6 +1564,7 @@ void AnimationPlayerEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_animation_edit"), &AnimationPlayerEditor::_animation_edit); ClassDB::bind_method(D_METHOD("_animation_resource_edit"), &AnimationPlayerEditor::_animation_resource_edit); ClassDB::bind_method(D_METHOD("_animation_player_changed"), &AnimationPlayerEditor::_animation_player_changed); + ClassDB::bind_method(D_METHOD("_animation_libraries_updated"), &AnimationPlayerEditor::_animation_libraries_updated); ClassDB::bind_method(D_METHOD("_list_changed"), &AnimationPlayerEditor::_list_changed); ClassDB::bind_method(D_METHOD("_animation_duplicate"), &AnimationPlayerEditor::_animation_duplicate); |