Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

Debug.DrawRay

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
public static function DrawRay(start: Vector3, dir: Vector3, color: Color = Color.white, duration: float = 0.0f, depthTest: bool = true): void;
public static void DrawRay(Vector3 start, Vector3 dir, Color color = Color.white, float duration = 0.0f, bool depthTest = true);
public static function DrawRay(start: Vector3, dir: Vector3, color: Color = Color.white, duration: float = 0.0f, depthTest: bool = true): void;
public static void DrawRay(Vector3 start, Vector3 dir, Color color = Color.white, float duration = 0.0f, bool depthTest = true);
public static function DrawRay(start: Vector3, dir: Vector3, color: Color = Color.white, duration: float = 0.0f, depthTest: bool = true): void;
public static void DrawRay(Vector3 start, Vector3 dir, Color color = Color.white, float duration = 0.0f, bool depthTest = true);
public static function DrawRay(start: Vector3, dir: Vector3, color: Color = Color.white, duration: float = 0.0f, depthTest: bool = true): void;
public static void DrawRay(Vector3 start, Vector3 dir, Color color = Color.white, float duration = 0.0f, bool depthTest = true);

Parámetros

start Point in world space where the ray should start.
dir Direction and length of the ray.
color Color of the drawn line.
duration How long the line will be visible for (in seconds).
depthTest Should the line be obscured by other objects closer to the camera?

Descripción

Draws a line from start to start + dir in world coordinates.

The duration parameter determines how long the line will be visible after the frame it is drawn. If duration is 0 (the default) then the line is rendered 1 frame.

If depthTest is set to true then the line will be obscured by other objects in the scene that are nearer to the camera.

The line will be drawn in the scene view of the editor. If gizmo drawing is enabled in the game view, the line will also be drawn there.

	// Frame update example: Draws a 10 meter long green line from the position for 1 frame.
	function Update () {
		var forward : Vector3 = transform.TransformDirection(Vector3.forward) * 10;
		Debug.DrawRay (transform.position, forward, Color.green);
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { Vector3 forward = transform.TransformDirection(Vector3.forward) * 10; Debug.DrawRay(transform.position, forward, Color.green); } }
	
	// Event callback example: Debug-draw all contact points and normals for 2 seconds.
	function OnCollisionEnter(collision : Collision) {
		for (var contact : ContactPoint in collision.contacts) {
			Debug.DrawRay(contact.point, contact.normal, Color.green, 2, false);
		}
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void OnCollisionEnter(Collision collision) { foreach (ContactPoint contact in collision.contacts) { Debug.DrawRay(contact.point, contact.normal, Color.green, 2, false); } } }