OnDrawGizmos DrawLine Gradation

In scene view, at first, I draw arrow line, but it seems not professional. So I write DrawGradientLine.

f:id:peroon:20180904135655p:plain

    void OnDrawGizmos()
    {
#if UNITY_EDITOR
        base.OnDrawGizmos();
        if (destination)
        {
            DrawGradientLine(transform.position, destination.position, Color.yellow, Color.red);
        }
#endif
    }

    private void DrawGradientLine(Vector3 from, Vector3 to, Color tailColor, Color headColor) {
        int divideNum = 5;
        Vector3 unitVector = (to - from) / divideNum;
        float colorChangeRatio = 1.0f / (divideNum - 1);
        for (int i=0; i<divideNum; i++)
        {
            float headColorRatio = i * colorChangeRatio;
            Color lineColor = tailColor * (1-headColorRatio) + headColor * headColorRatio;
            Gizmos.color = lineColor;
            Gizmos.DrawLine(from + unitVector * i, from + unitVector * (i + 1));
        }
    }

extra

    private void DrawArrow(Vector3 from, Vector3 to, Color color)
    {
        Gizmos.color = color;
        Gizmos.DrawLine(from, to);

        // arrow
        Vector3 v = (from - to).normalized;
        var v2 = Quaternion.AngleAxis(30, Vector3.up) * v;
        var v3 = Quaternion.AngleAxis(-30, Vector3.up) * v;
        Gizmos.DrawLine(to, to + v2);
        Gizmos.DrawLine(to, to + v3);
    }