从 from
开始向 to
绘制一条线。
如果您需要绘制多条线,请考虑使用 Gizmos.DrawLineList 或 Gizmos.DrawLineStrip 函数,它们比重复调用此函数分别绘制各条线要快得多。
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public Transform target;
void OnDrawGizmosSelected() { if (target != null) { // Draws a blue line from this transform to the target Gizmos.color = Color.blue; Gizmos.DrawLine(transform.position, target.position); } } }