Untitled

 avatar
unknown
csharp
4 years ago
885 B
8
Indexable
        public static void DrawCircle(float radius, Vector3 center, Vector3 normal, Vector3 right, int circleResolution) {
            float angleSlice = (360 / (float) circleResolution) * Mathf.Deg2Rad;
            Vector3 side = right.normalized;
            Vector3 up = Vector3.Cross(normal, right).normalized;
            
            List<Vector3> points = new List<Vector3>();

            for (int i = 0; i < circleResolution; i++) {
                Vector3 pos = center;
                pos += radius * Mathf.Sin(i * angleSlice) * side;
                pos += radius * Mathf.Cos(i * angleSlice) * up;
                points.Add(pos);
            }

            for (int i = 0; i < points.Count - 1; i++) {
                Gizmos.DrawLine(points[i], points[i + 1]);
            }

            Gizmos.DrawLine(points[points.Count - 1], points[0]);

        }
Editor is loading...