Exemplo n.º 1
0
    public static void DrawCircle(Vector3 origin, float radius, Quaternion rotation, float startAngle, float endAngle, Color color, float duration)
    {
#if !UNITY_EDITOR
        return;
#else
        float   resolution = 24;
        Vector3 lastPoint  = Vector3.zero;
        for (var i = 0; i <= resolution; ++i)
        {
            float angle = (i / resolution) * Mathf.PI * 2;

            float x         = Mathf.Cos(angle);
            float y         = Mathf.Sin(angle);
            var   thisPoint = new Vector3(x, y, 0);
            thisPoint = origin + rotation * (thisPoint * radius);
            if (i > 0)
            {
                if (Mathfx.BetweenInclusive(angle, startAngle, endAngle))
                {
                    Debug.DrawLine(lastPoint, thisPoint, color, duration);
                }
            }
            lastPoint = thisPoint;
        }
#endif
    }