From 9b1a1d2813cdd913b5b88c531a2adfa5127d3f66 Mon Sep 17 00:00:00 2001 From: Steven Thompson Date: Wed, 3 Apr 2024 20:05:17 +0100 Subject: [PATCH] Fix gizmo on top material option having no effect Update get_material function in EditorNode3DGizmoPlugin so that it enables the disable depth test flag on duplicate versions of the gizmo materials if the flag is not already set and the gizmo is set to use the 'x-ray' visibility state. --- editor/plugins/node_3d_editor_gizmos.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 085e8cddbea2..7e98950f3212 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -979,10 +979,11 @@ Ref EditorNode3DGizmoPlugin::get_material(const String &p_na Ref mat = materials[p_name][index]; - if (current_state == ON_TOP && p_gizmo->is_selected()) { + bool on_top_mat = mat->get_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST); + + if (!on_top_mat && current_state == ON_TOP && p_gizmo->is_selected()) { + mat = mat->duplicate(); mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); - } else { - mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, false); } return mat;