Version: 2023.1
public static Rendering.CompareFunction zTest ;

描述

手柄的 zTest。

默认值为 Always。

\ 此锚点显示第一个向下碰撞体交叉点。深度通道线显示为绿色,若深度测试失败,则显示为红色。

要使用此示例,请将此脚本附加到您希望向其显示锚点的对象:

using UnityEngine;
using UnityEditor;

[ExecuteInEditMode] public class SampleAnchor : MonoBehaviour { void OnDrawGizmosSelected() { Ray ray = new Ray(transform.position, Vector3.down); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Handles.color = Color.green; Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual; Handles.DrawLine(transform.position, hit.point); Handles.DrawWireDisc(hit.point, hit.normal, 0.5f);

Handles.color = Color.red; Handles.zTest = UnityEngine.Rendering.CompareFunction.Greater; Handles.DrawLine(transform.position, hit.point); Handles.DrawWireDisc(hit.point, hit.normal, 0.5f); } } }