using UnityEngine; using System.Collections; public class TestCube : MonoBehaviour { void OnDrawGizmos() { var direction = transform.TransformDirection(Vector3.up) * 5; // 在物体的前方绘制一个5米长的线 Gizmos.color = Color.green; Gizmos.DrawRay(transform.position, direction); DrawShexian(); } void OnDrawGizmosSelected() { } private void DrawShexian() { Gizmos.color = Color.red; var direction = transform.TransformDirection(Vector3.forward) * 5; // 在物体的前方绘制一个5米长的线 Gizmos.DrawRay(transform.position, direction); Gizmos.color = Color.blue; var d = transform.TransformDirection(Vector3.right) * 5; // 在物体的前方绘制一个5米长的线 Gizmos.DrawRay(transform.position, d); } }