public static class DebugCustomUtil
{
public static void DrawCircle(Vector3 pos, float radius, float duration=0, Color? color =null, int segments = 32)
{
// 원 나누기. 라인으로 그리니까 라인을 몇번 그릴 건지.
// segments 가 크면 부드러운 원이 됨.
float angleStep = 360f / segments;
// 색 기본 설정
Color drawColor = color ?? Color.red;
// 처음 그릴 라인의 시작 점
Vector3 prePoint = pos + new Vector3(Mathf.Cos(0), Mathf.Sin(0), 0) * radius;
for (int i = 1; i <= segments; ++i)
{
// 각도를 라디안으로 변환해서 써야함
float angle = angleStep * i * Mathf.Deg2Rad;
// 라인이 prePoint 부터 nextPoint 까지 그려짐.
// 다음 라인을 위해 prePoint = nextPoint
Vector3 nextPoint = pos + new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0) * radius;
Debug.DrawLine(prePoint, nextPoint, drawColor, duration);
prePoint = nextPoint;
}
}
}