Unity3D engine technology exchange QQ group: [21568554]
Gizmos is a visual debugging tool in the scenario view. We often use it during the project process, for example, drawing a ray.
As of Unity3D 4.2, only the rendering Ray, line segment, grid sphere, Solid Sphere, grid cube, solid cube, icon, GUI texture, and camera wiremap are available.
If you need to draw a ring, you also need to write your own code.
Using UnityEngine; using System; public class HeGizmosCircle: MonoBehaviour {public Transform m_Transform; public float m_Radius = 1; // the radius of the ring public float m_Theta = 0.1f; // The lower the value, the smoother the ring. public Color m_Color = Color. green; // wiremap color void Start () {if (m_Transform = null) {throw new Exception ("Transform is NULL. ") ;}} void OnDrawGizmos () {if (m_Transform = null) return; if (m_Theta <0.0001f) m_Theta = 0.0001f; // sets the matrix Matrix4x4 defaultMatrix = Gizmos. matrix; Gizmos. matrix = m_Transform.localToWorldMatrix; // set the Color defaultColor = Gizmos. color; Gizmos. color = m_Color; // plot the ring Vector3 beginPoint = Vector3.zero; Vector3 firstPoint = Vector3.zero; for (float theta = 0; theta <2 * Mathf. PI; theta + = m_Theta) {float x = m_Radius * Mathf. cos (theta); float z = m_Radius * Mathf. sin (theta); Vector3 endPoint = new Vector3 (x, 0, z); if (theta = 0) {firstPoint = endPoint;} else {Gizmos. drawLine (beginPoint, endPoint);} beginPoint = endPoint;} // draw the last line segment Gizmos. drawLine (firstPoint, beginPoint); // restores the default Gizmos color. color = defaultColor; // restore the default matrix Gizmos. matrix = defaultMatrix ;}}
Drag the code to a GameObject and associate the Transform of the GameObject. Then, a circle is displayed in the Scene View window.
Adjust the Position, Rotation, and scaling of the circle by adjusting the Position, Rotation, and Scale of the Transform.