1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

-Properly keep animation editor and viewport state while switching scene tabs

This commit is contained in:
Juan Linietsky
2015-08-29 22:59:25 -03:00
parent b4acd18f32
commit 1bad27e1f8
4 changed files with 67 additions and 1 deletions

View File

@@ -549,6 +549,49 @@ void AnimationPlayerEditor::ensure_visibility() {
_animation_edit();
}
Dictionary AnimationPlayerEditor::get_state() const {
Dictionary d;
d["visible"]=is_visible();
if (is_visible() && player) {
d["player"]=EditorNode::get_singleton()->get_edited_scene()->get_path_to(player);
d["animation"]=player->get_current_animation();
d["editing"]=edit_anim->is_pressed();
}
return d;
}
void AnimationPlayerEditor::set_state(const Dictionary& p_state) {
if (p_state.has("visible") && p_state["visible"]) {
Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]);
if (n && n->cast_to<AnimationPlayer>()) {
player=n->cast_to<AnimationPlayer>();
_update_player();
show();
set_process(true);
ensure_visibility();
EditorNode::get_singleton()->animation_panel_make_visible(true);
if (p_state.has("animation")) {
String anim = p_state["animation"];
_select_anim_by_name(anim);
if (p_state.has("editing") && p_state["editing"]) {
edit_anim->set_pressed(true);
_animation_edit();
}
}
}
}
}
void AnimationPlayerEditor::_animation_resource_edit() {
if (animation->get_item_count()) {