12345678910111213141516171819202122232425262728293031 |
- 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);
- }
- }
|