Fix collapse visual shader tree

This commit is contained in:
Chaosus 2019-05-03 11:10:08 +03:00
parent 0619d5d7b2
commit 8a8b7af638

View File

@ -58,9 +58,15 @@ void VisualShaderNodePlugin::_bind_methods() {
void VisualShaderEditor::edit(VisualShader *p_visual_shader) { void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
bool first_init = false; bool changed = false;
if (p_visual_shader) { if (p_visual_shader) {
first_init = true; if (visual_shader.is_null()) {
changed = true;
} else {
if (visual_shader.ptr() != p_visual_shader) {
changed = true;
}
}
visual_shader = Ref<VisualShader>(p_visual_shader); visual_shader = Ref<VisualShader>(p_visual_shader);
} else { } else {
visual_shader.unref(); visual_shader.unref();
@ -69,7 +75,7 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
if (visual_shader.is_null()) { if (visual_shader.is_null()) {
hide(); hide();
} else { } else {
if (first_init) { // to avoid tree collapse if (changed) { // to avoid tree collapse
_update_options_menu(); _update_options_menu();
} }
_update_graph(); _update_graph();