@@ -6395,38 +6395,34 @@ void Node3DEditor::_generate_selection_boxes() {
63956395 const Color selection_box_color = EDITOR_GET (" editors/3d/selection_box_color" );
63966396 const Color active_selection_box_color = EDITOR_GET (" editors/3d/active_selection_box_color" );
63976397
6398- Ref<StandardMaterial3D> mat = memnew (StandardMaterial3D);
6399- mat->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6400- mat->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6401- mat->set_albedo (selection_box_color);
6402- mat->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6403- st->set_material (mat);
6398+ selection_box_mat->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6399+ selection_box_mat->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6400+ selection_box_mat->set_albedo (selection_box_color);
6401+ selection_box_mat->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6402+ st->set_material (selection_box_mat);
64046403 selection_box = st->commit ();
64056404
6406- Ref<StandardMaterial3D> mat_xray = memnew (StandardMaterial3D);
6407- mat_xray->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6408- mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6409- mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true );
6410- mat_xray->set_albedo (selection_box_color * Color (1 , 1 , 1 , 0.15 ));
6411- mat_xray->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6412- st_xray->set_material (mat_xray);
6405+ selection_box_mat_xray->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6406+ selection_box_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6407+ selection_box_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true );
6408+ selection_box_mat_xray->set_albedo (selection_box_color * Color (1 , 1 , 1 , 0.15 ));
6409+ selection_box_mat_xray->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6410+ st_xray->set_material (selection_box_mat_xray);
64136411 selection_box_xray = st_xray->commit ();
64146412
6415- Ref<StandardMaterial3D> active_mat = memnew (StandardMaterial3D);
6416- active_mat->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6417- active_mat->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6418- active_mat->set_albedo (active_selection_box_color);
6419- active_mat->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6420- active_st->set_material (active_mat);
6413+ active_selection_box_mat->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6414+ active_selection_box_mat->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6415+ active_selection_box_mat->set_albedo (active_selection_box_color);
6416+ active_selection_box_mat->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6417+ active_st->set_material (active_selection_box_mat);
64216418 active_selection_box = active_st->commit ();
64226419
6423- Ref<StandardMaterial3D> active_mat_xray = memnew (StandardMaterial3D);
6424- active_mat_xray->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6425- active_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6426- active_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true );
6427- active_mat_xray->set_albedo (active_selection_box_color * Color (1 , 1 , 1 , 0.15 ));
6428- active_mat_xray->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6429- active_st_xray->set_material (active_mat_xray);
6420+ active_selection_box_mat_xray->set_shading_mode (StandardMaterial3D::SHADING_MODE_UNSHADED);
6421+ active_selection_box_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_FOG, true );
6422+ active_selection_box_mat_xray->set_flag (StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true );
6423+ active_selection_box_mat_xray->set_albedo (active_selection_box_color * Color (1 , 1 , 1 , 0.15 ));
6424+ active_selection_box_mat_xray->set_transparency (StandardMaterial3D::TRANSPARENCY_ALPHA);
6425+ active_st_xray->set_material (active_selection_box_mat_xray);
64306426 active_selection_box_xray = active_st_xray->commit ();
64316427}
64326428
@@ -8282,8 +8278,21 @@ void Node3DEditor::_notification(int p_what) {
82828278 } break ;
82838279
82848280 case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
8285- // Update grid color by rebuilding grid.
82868281 if (EditorSettings::get_singleton ()->check_changed_settings_in_group (" editors/3d" )) {
8282+ const Color selection_box_color = EDITOR_GET (" editors/3d/selection_box_color" );
8283+ const Color active_selection_box_color = EDITOR_GET (" editors/3d/active_selection_box_color" );
8284+
8285+ if (selection_box_color != selection_box_mat->get_albedo ()) {
8286+ selection_box_mat->set_albedo (selection_box_color);
8287+ selection_box_mat_xray->set_albedo (selection_box_color * Color (1 , 1 , 1 , 0.15 ));
8288+ }
8289+
8290+ if (active_selection_box_color != active_selection_box_mat->get_albedo ()) {
8291+ active_selection_box_mat->set_albedo (active_selection_box_color);
8292+ active_selection_box_mat_xray->set_albedo (active_selection_box_color * Color (1 , 1 , 1 , 0.15 ));
8293+ }
8294+
8295+ // Update grid color by rebuilding grid.
82878296 _finish_grid ();
82888297 _init_grid ();
82898298 }
0 commit comments