Gizmos-绘制坐标轴方向的辅助线
作者:互联网
#
#if UNITY_EDITOR using UnityEditor; using UnityEngine; public class GizmosDrawAxis : MonoBehaviour { public Color color = Color.yellow; public bool isSelectedDraw = false; [Range(1, 20)] public float length = 5; public bool upLineShow = true; public bool forwardLineShow = true; public bool rightLineShow = true; [DrawGizmo(GizmoType.Selected | GizmoType.NonSelected)] static void MyDrawGizmos(GizmosDrawAxis target, GizmoType gizmoType) { if (!target.isSelectedDraw && 0 != (gizmoType & GizmoType.Selected)) { return; } var transform = target.transform; var colorBak = Gizmos.color; Gizmos.color = target.color; var myPos = transform.position; if (target.upLineShow) { var upPos = myPos + transform.up * target.length; Gizmos.DrawLine(myPos, upPos); } if (target.forwardLineShow) { var forwardPos = myPos + transform.forward * target.length; Gizmos.DrawLine(myPos, forwardPos); } if (target.rightLineShow) { var rightPos = myPos + transform.right * target.length; Gizmos.DrawLine(myPos, rightPos); } Gizmos.color = colorBak; } } #endif
【关于Gizmos如何翻译?】
小工具? 一些小工具? 各类小工具? 一系列辅助工具? 小的指示器?
【参考】
Unity 小工具菜单(Gizmos menu)_w3cschool
标签:target,transform,辅助线,坐标轴,var,Gizmos,public,myPos 来源: https://www.cnblogs.com/sailJs/p/16384996.html