绘制辅助线框——Gizmos

作者:追风剑情 发布于:2015-12-29 16:52 分类:Unity3d

一、创建一个空GameObject和脚本GizmosTest.cs

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. [ExecuteInEditMode]//让脚本在编辑模式下运行
  5. public class GizmosTest : MonoBehaviour {
  6.  
  7. Transform mTran;
  8.  
  9. void Start()
  10. {
  11. mTran = transform;
  12. }
  13.  
  14. void OnDrawGizmos()
  15. {
  16. Gizmos.color = Color.yellow;
  17. Gizmos.DrawWireCube(mTran.position, new Vector3(1, 1, 1));
  18. }
  19. }

Scene窗口中的效果

r1.png

 

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号