Unity3d用Gizmos画一个圆圈

xiaoxiao2021-02-28  6

public int VertexCount = 50;//定义圆圈边定点数量,数值越高越平滑 public float Radius = 1;//圆形半径 public Vector3 Offset;//圆圈位移 void OnDrawGizmos() { float deltaTheta = (2f * Mathf.PI) / VertexCount; float theta = 0f; Vector3 oldPos = transform.position; for (int i = 0; i < VertexCount + 1; i++) { Vector3 pos = new Vector3(Radius * Mathf.Cos(theta), Radius * Mathf.Sin(theta), 0f); Gizmos.DrawLine(oldPos, transform.position + pos + Offset); Gizmos.color = Color.red; oldPos = transform.position + pos + Offset; theta += deltaTheta; } }
转载请注明原文地址: https://www.6miu.com/read-1150230.html

最新回复(0)