Gizmos.DrawRay 绘制射线
static function DrawRay (r : Ray) : void
static function DrawRay (from : Vector3, direction : Vector3) : void
Description描述
Draws a ray starting at from to from + direction.
绘制一条射线从from起点到direction方向和位置。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void OnDrawGizmosSelected() {
Gizmos.color = Color.red;
Vector3 direction = transform.TransformDirection(Vector3.forward) * 5;
Gizmos.DrawRay(transform.position, direction);
}
}
function OnDrawGizmosSelected () {
// Draws a 5 meter long red line in front of the object
//在物体的前面绘制一个5米长红色的线
Gizmos.color = Color.red;
var direction : Vector3 = transform.TransformDirection (Vector3.forward) * 5;
Gizmos.DrawRay (transform.position, direction);
}
最后修改:2010年12月25日 Saturday 23:15