Gizmos.DrawLine 绘制线

static function DrawLine (from : Vector3, to : Vector3) : void

Description描述

Draws a line starting at from towards to.

绘制一条线从from起点到to位置。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Transform target;
	void OnDrawGizmosSelected() {
		if (target != null) {
			Gizmos.color = Color.blue;
			Gizmos.DrawLine(transform.position, target.position);
		}
	}
}
var target : Transform;
function OnDrawGizmosSelected () {
	if(target != null) {
		// Draws a blue line from this transform to the target
		//绘制一条蓝色的线,从该变换到目标位置
		Gizmos.color = Color.blue;
		Gizmos.DrawLine (transform.position, target.position);
	}
}
Page last updated: 2010-12-25