瀏覽代碼

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.
Steven Thompson 1 年之前
父節點
當前提交
9b1a1d2813
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      editor/plugins/node_3d_editor_gizmos.cpp

+ 4 - 3
editor/plugins/node_3d_editor_gizmos.cpp

@@ -979,10 +979,11 @@ Ref<StandardMaterial3D> EditorNode3DGizmoPlugin::get_material(const String &p_na
 
 	Ref<StandardMaterial3D> 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;