using UnityEngine; public class DrawUtility { // ------------------------------------------------------------------ // Desc: DrawCircle // ------------------------------------------------------------------ // DrawCircleX public static void DrawCircleX(Vector3 _center, float _radius, Color _color, float _duration = 0.0f, bool _depthTets = true) { DrawCircle(Quaternion.Euler(0.0f, 0.0f, 90.0f), _center, _radius, _color, _duration, _depthTets); } // DrawCircleY public static void DrawCircleY(Vector3 _center, float _radius, Color _color, float _duration = 0.0f, bool _depthTets = true) { DrawCircle(Quaternion.identity, _center, _radius, _color, _duration, _depthTets); } // DrawCircleZ public static void DrawCircleZ(Vector3 _center, float _radius, Color _color, float _duration = 0.0f, bool _depthTets = true) { DrawCircle(Quaternion.Euler(90.0f, 0.0f, 0.0f), _center, _radius, _color, _duration, _depthTets); } public static void DrawTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Color color) { Debug.DrawLine(p1, p2, color); Debug.DrawLine(p2, p3, color); Debug.DrawLine(p3, p1, color); } public static void DrawCircle(Quaternion _rot, Vector3 _center, float _radius, Color _color, float _duration = 0.0f, bool _depthTets = true) { #if UNITY_EDITOR // float two_pi = 2.0f * Mathf.PI; float segments = 32.0f; float step = two_pi / segments; float theta = 0.0f; // Vector3 last = _center + _rot * (_radius * new Vector3(Mathf.Cos(theta), 0.0f, Mathf.Sin(theta))); theta += step; // for (int i = 1; i <= segments; ++i) { Vector3 cur = _center + _rot * (_radius * new Vector3(Mathf.Cos(theta), 0.0f, Mathf.Sin(theta))); Debug.DrawLine(last, cur, _color, _duration, _depthTets); last = cur; theta += step; } #endif } // ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public static void DrawBall(Vector3 _center, float _radius, Color _color, float _duration = 0.0f, bool _depthTets = true) { DrawCircleX(_center, _radius, _color, _duration, _depthTets); DrawCircleY(_center, _radius, _color, _duration, _depthTets); DrawCircleZ(_center, _radius, _color, _duration, _depthTets); } }