diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index a246249cfe3..a49d4489ed7 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -765,7 +765,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d/secondary_grid_color", Color(0.38, 0.38, 0.38, 0.5), "") // Use a similar color to the 2D editor selection. - EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d/selection_box_color", Color(1.0, 0.5, 0), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) + EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d/selection_box_color", Color(1.0, 0.5, 0), "", PROPERTY_USAGE_DEFAULT) EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_colors/aabb", Color(0.28, 0.8, 0.82), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 058adbdb197..269188317eb 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -6380,22 +6380,20 @@ void Node3DEditor::_generate_selection_boxes() { st_xray->add_vertex(b); } - Ref mat = memnew(StandardMaterial3D); - mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - mat->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true); + selection_box_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + selection_box_mat->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true); const Color selection_box_color = EDITOR_GET("editors/3d/selection_box_color"); - mat->set_albedo(selection_box_color); - mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - st->set_material(mat); + selection_box_mat->set_albedo(selection_box_color); + selection_box_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + st->set_material(selection_box_mat); selection_box = st->commit(); - Ref mat_xray = memnew(StandardMaterial3D); - mat_xray->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - mat_xray->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true); - mat_xray->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); - mat_xray->set_albedo(selection_box_color * Color(1, 1, 1, 0.15)); - mat_xray->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - st_xray->set_material(mat_xray); + selection_box_mat_xray->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + selection_box_mat_xray->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true); + selection_box_mat_xray->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); + selection_box_mat_xray->set_albedo(selection_box_color * Color(1, 1, 1, 0.15)); + selection_box_mat_xray->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + st_xray->set_material(selection_box_mat_xray); selection_box_xray = st_xray->commit(); } @@ -8224,8 +8222,15 @@ void Node3DEditor::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - // Update grid color by rebuilding grid. if (EditorSettings::get_singleton()->check_changed_settings_in_group("editors/3d")) { + const Color selection_box_color = EDITOR_GET("editors/3d/selection_box_color"); + + if (selection_box_color != selection_box_mat->get_albedo()) { + selection_box_mat->set_albedo(selection_box_color); + selection_box_mat_xray->set_albedo(selection_box_color * Color(1, 1, 1, 0.15)); + } + + // Update grid color by rebuilding grid. _finish_grid(); _init_grid(); } diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index 27c709fb064..faa82407ac1 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -696,6 +696,10 @@ private: Ref selection_box_xray; Ref selection_box; + + Ref selection_box_mat = memnew(StandardMaterial3D); + Ref selection_box_mat_xray = memnew(StandardMaterial3D); + RID indicators; RID indicators_instance; RID cursor_mesh;