Version: 5.6 (switch to 2017.1b)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Handles.zTest

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static var zTest: Rendering.CompareFunction;
public static Rendering.CompareFunction zTest;

Description

zTest of the handles.

Default value is Always.


This anchor shows the first downwards collider intersection. Depth pass lines appears green, depth fail, red.

To use this example, attach this script to the object you wish to display the anchor :

#pragma strict
@ExecuteInEditMode
public class SampleAnchor extends MonoBehaviour {
	function OnDrawGizmosSelected() {
		var ray: Ray = new Ray(transform.position, Vector3.down);
		var hit: RaycastHit;
		if (Physics.Raycast(ray, 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);
		}
	}
}
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); } } }