diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-09-17 12:43:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-17 12:43:01 +0200 |
commit | a29559bc0e8bfbfcab7e0f4b05b9e77119d71ce0 (patch) | |
tree | c7615e0378cf452061b0a9c62941d27abc325bf6 | |
parent | 3e66cd9b6862ffd6991dba7c7cad5a175b8db320 (diff) | |
parent | 9e204658ff8d943e363cf3682e61ff01c1388805 (diff) |
Merge pull request #11075 from ISylvox/fix-main-scene-state
Fixes Tab Switching of Main Scene State. Closes #11045
-rw-r--r-- | editor/editor_node.cpp | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6424e03aea..58703ccf9d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2780,14 +2780,6 @@ Dictionary EditorNode::_get_main_scene_state() { state["property_edit_offset"] = get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_value(); state["saved_version"] = saved_version; state["node_filter"] = scene_tree_dock->get_filter(); - int current = -1; - for (int i = 0; i < editor_table.size(); i++) { - if (editor_plugin_screen == editor_table[i]) { - current = i; - break; - } - } - state["editor_index"] = current; return state; } @@ -2798,29 +2790,32 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { changing_scene = false; - if (p_state.has("editor_index")) { - - int index = p_state["editor_index"]; - int current = -1; - for (int i = 0; i < editor_table.size(); i++) { - if (editor_plugin_screen == editor_table[i]) { - current = i; - break; - } + int current = -1; + for (int i = 0; i < editor_table.size(); i++) { + if (editor_plugin_screen == editor_table[i]) { + current = i; + break; } + } + if (p_state.has("editor_index")) { + int index = p_state["editor_index"]; if (current < 2) { //if currently in spatial/2d, only switch to spatial/2d. if curently in script, stay there if (index < 2 || !get_edited_scene()) { _editor_select(index); - } else { - //use heuristic instead - int n2d = 0, n3d = 0; - _find_node_types(get_edited_scene(), n2d, n3d); - if (n2d > n3d) { - _editor_select(EDITOR_2D); - } else if (n3d > n2d) { - _editor_select(EDITOR_3D); - } + } + } + } + + if (get_edited_scene()) { + if (current < 2) { + //use heuristic instead + int n2d = 0, n3d = 0; + _find_node_types(get_edited_scene(), n2d, n3d); + if (n2d > n3d) { + _editor_select(EDITOR_2D); + } else if (n3d > n2d) { + _editor_select(EDITOR_3D); } } } |