Do not require editor restart when changing selection box color
This commit is contained in:
parent
7893202fba
commit
8a6804b197
3 changed files with 43 additions and 29 deletions
|
|
@ -6395,38 +6395,34 @@ void Node3DEditor::_generate_selection_boxes() {
|
|||
const Color selection_box_color = EDITOR_GET("editors/3d/selection_box_color");
|
||||
const Color active_selection_box_color = EDITOR_GET("editors/3d/active_selection_box_color");
|
||||
|
||||
Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
|
||||
mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
|
||||
mat->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
|
||||
mat->set_albedo(selection_box_color);
|
||||
mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
|
||||
st->set_material(mat);
|
||||
selection_box_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
|
||||
selection_box_mat->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
|
||||
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<StandardMaterial3D> 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();
|
||||
|
||||
Ref<StandardMaterial3D> active_mat = memnew(StandardMaterial3D);
|
||||
active_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
|
||||
active_mat->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
|
||||
active_mat->set_albedo(active_selection_box_color);
|
||||
active_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
|
||||
active_st->set_material(active_mat);
|
||||
active_selection_box_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
|
||||
active_selection_box_mat->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
|
||||
active_selection_box_mat->set_albedo(active_selection_box_color);
|
||||
active_selection_box_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
|
||||
active_st->set_material(active_selection_box_mat);
|
||||
active_selection_box = active_st->commit();
|
||||
|
||||
Ref<StandardMaterial3D> active_mat_xray = memnew(StandardMaterial3D);
|
||||
active_mat_xray->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
|
||||
active_mat_xray->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
|
||||
active_mat_xray->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
|
||||
active_mat_xray->set_albedo(active_selection_box_color * Color(1, 1, 1, 0.15));
|
||||
active_mat_xray->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
|
||||
active_st_xray->set_material(active_mat_xray);
|
||||
active_selection_box_mat_xray->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
|
||||
active_selection_box_mat_xray->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
|
||||
active_selection_box_mat_xray->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
|
||||
active_selection_box_mat_xray->set_albedo(active_selection_box_color * Color(1, 1, 1, 0.15));
|
||||
active_selection_box_mat_xray->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
|
||||
active_st_xray->set_material(active_selection_box_mat_xray);
|
||||
active_selection_box_xray = active_st_xray->commit();
|
||||
}
|
||||
|
||||
|
|
@ -8282,8 +8278,21 @@ 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");
|
||||
const Color active_selection_box_color = EDITOR_GET("editors/3d/active_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));
|
||||
}
|
||||
|
||||
if (active_selection_box_color != active_selection_box_mat->get_albedo()) {
|
||||
active_selection_box_mat->set_albedo(active_selection_box_color);
|
||||
active_selection_box_mat_xray->set_albedo(active_selection_box_color * Color(1, 1, 1, 0.15));
|
||||
}
|
||||
|
||||
// Update grid color by rebuilding grid.
|
||||
_finish_grid();
|
||||
_init_grid();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -698,6 +698,11 @@ private:
|
|||
Ref<ArrayMesh> selection_box_xray;
|
||||
Ref<ArrayMesh> selection_box;
|
||||
|
||||
Ref<StandardMaterial3D> selection_box_mat = memnew(StandardMaterial3D);
|
||||
Ref<StandardMaterial3D> selection_box_mat_xray = memnew(StandardMaterial3D);
|
||||
Ref<StandardMaterial3D> active_selection_box_mat = memnew(StandardMaterial3D);
|
||||
Ref<StandardMaterial3D> active_selection_box_mat_xray = memnew(StandardMaterial3D);
|
||||
|
||||
RID indicators;
|
||||
RID indicators_instance;
|
||||
RID cursor_mesh;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue