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

Fix shader editor auto-opens on startup

This commit is contained in:
LuoZhihao
2025-07-05 06:16:37 +08:00
parent 53be3b78d1
commit 4e991bf8f7
2 changed files with 11 additions and 9 deletions

View File

@@ -266,7 +266,7 @@ void ShaderEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
}
_update_shader_list();
_shader_selected(selected_shader_idx);
_shader_selected(selected_shader_idx, false);
_set_text_shader_zoom_factor(p_layout->get_value("ShaderEditor", "text_shader_zoom_factor", 1.0f));
}
@@ -370,7 +370,7 @@ void ShaderEditorPlugin::apply_changes() {
}
}
void ShaderEditorPlugin::_shader_selected(int p_index) {
void ShaderEditorPlugin::_shader_selected(int p_index, bool p_push_item) {
if (p_index >= (int)edited_shaders.size()) {
return;
}
@@ -383,11 +383,13 @@ void ShaderEditorPlugin::_shader_selected(int p_index) {
shader_tabs->set_current_tab(p_index);
shader_list->select(p_index);
// Avoid `Shader` being edited when editing `ShaderInclude` due to inspector refreshing.
if (edited_shaders[p_index].shader.is_valid()) {
EditorNode::get_singleton()->push_item_no_inspector(edited_shaders[p_index].shader.ptr());
} else {
EditorNode::get_singleton()->push_item_no_inspector(edited_shaders[p_index].shader_inc.ptr());
if (p_push_item) {
// Avoid `Shader` being edited when editing `ShaderInclude` due to inspector refreshing.
if (edited_shaders[p_index].shader.is_valid()) {
EditorNode::get_singleton()->push_item_no_inspector(edited_shaders[p_index].shader.ptr());
} else {
EditorNode::get_singleton()->push_item_no_inspector(edited_shaders[p_index].shader_inc.ptr());
}
}
}
@@ -929,7 +931,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
shader_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
shader_list->set_theme_type_variation("ItemListSecondary");
files_split->add_child(shader_list);
shader_list->connect(SceneStringName(item_selected), callable_mp(this, &ShaderEditorPlugin::_shader_selected));
shader_list->connect(SceneStringName(item_selected), callable_mp(this, &ShaderEditorPlugin::_shader_selected).bind(true));
shader_list->connect("item_clicked", callable_mp(this, &ShaderEditorPlugin::_shader_list_clicked));
shader_list->set_allow_rmb_select(true);
SET_DRAG_FORWARDING_GCD(shader_list, ShaderEditorPlugin);