@@ -6426,38 +6426,34 @@ void Node3DEditor::_generate_selection_boxes() {
64266426 const Color selection_box_color = EDITOR_GET (" editors/3d/selection_box_color" );
64276427 const Color active_selection_box_color = EDITOR_GET (" editors/3d/active_selection_box_color" );
64286428
6429- Ref<StandardMaterial3D> mat = memnew (StandardMaterial3D);
6430- mat->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6431- mat->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6432- mat->set_albedo (selection_box_color);
6433- mat->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6434- st->set_material (mat);
6429+ selection_box_mat->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6430+ selection_box_mat->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6431+ selection_box_mat->set_albedo (selection_box_color);
6432+ selection_box_mat->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6433+ st->set_material (selection_box_mat);
64356434 selection_box = st->commit ();
64366435
6437- Ref<StandardMaterial3D> mat_xray = memnew (StandardMaterial3D);
6438- mat_xray->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6439- mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6440- mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true );
6441- mat_xray->set_albedo (selection_box_color * Color (1 , 1 , 1 , 0.15 ));
6442- mat_xray->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6443- st_xray->set_material (mat_xray);
6436+ selection_box_mat_xray->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6437+ selection_box_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6438+ selection_box_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true );
6439+ selection_box_mat_xray->set_albedo (selection_box_color * Color (1 , 1 , 1 , 0.15 ));
6440+ selection_box_mat_xray->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6441+ st_xray->set_material (selection_box_mat_xray);
64446442 selection_box_xray = st_xray->commit ();
64456443
6446- Ref<StandardMaterial3D> active_mat = memnew (StandardMaterial3D);
6447- active_mat->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6448- active_mat->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6449- active_mat->set_albedo (active_selection_box_color);
6450- active_mat->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6451- active_st->set_material (active_mat);
6444+ active_selection_box_mat->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6445+ active_selection_box_mat->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6446+ active_selection_box_mat->set_albedo (active_selection_box_color);
6447+ active_selection_box_mat->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6448+ active_st->set_material (active_selection_box_mat);
64526449 active_selection_box = active_st->commit ();
64536450
6454- Ref<StandardMaterial3D> active_mat_xray = memnew (StandardMaterial3D);
6455- active_mat_xray->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6456- active_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6457- active_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true );
6458- active_mat_xray->set_albedo (active_selection_box_color * Color (1 , 1 , 1 , 0.15 ));
6459- active_mat_xray->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6460- active_st_xray->set_material (active_mat_xray);
6451+ active_selection_box_mat_xray->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6452+ active_selection_box_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6453+ active_selection_box_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true );
6454+ active_selection_box_mat_xray->set_albedo (active_selection_box_color * Color (1 , 1 , 1 , 0.15 ));
6455+ active_selection_box_mat_xray->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6456+ active_st_xray->set_material (active_selection_box_mat_xray);
64616457 active_selection_box_xray = active_st_xray->commit ();
64626458}
64636459
@@ -8313,8 +8309,21 @@ void Node3DEditor::_notification(int p_what) {
83138309 } break ;
83148310
83158311 case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
8316- // Update grid color by rebuilding grid.
83178312 if (EditorSettings::get_singleton ()->check_changed_settings_in_group (" editors/3d" )) {
8313+ const Color selection_box_color = EDITOR_GET (" editors/3d/selection_box_color" );
8314+ const Color active_selection_box_color = EDITOR_GET (" editors/3d/active_selection_box_color" );
8315+
8316+ if (selection_box_color != selection_box_mat->get_albedo ()) {
8317+ selection_box_mat->set_albedo (selection_box_color);
8318+ selection_box_mat_xray->set_albedo (selection_box_color * Color (1 , 1 , 1 , 0.15 ));
8319+ }
8320+
8321+ if (active_selection_box_color != active_selection_box_mat->get_albedo ()) {
8322+ active_selection_box_mat->set_albedo (active_selection_box_color);
8323+ active_selection_box_mat_xray->set_albedo (active_selection_box_color * Color (1 , 1 , 1 , 0.15 ));
8324+ }
8325+
8326+ // Update grid color by rebuilding grid.
83188327 _finish_grid ();
83198328 _init_grid ();
83208329 }
0 commit comments