void drawLine(Vector2 pointA, Vector2 pointB, Color color, bool mouse, Texture2D srcAnchor, Texture2D destAnchor)
{
float width = 2;
Color savedColor = GUI.color;
Matrix4x4 savedMatrix = GUI.matrix;
width *= 3;
if (!lineTex) {
lineTex = new Texture2D (1, 3, TextureFormat.ARGB32, true);
lineTex.SetPixel (0, 0, new Color (1, 1, 1, 0));
lineTex.SetPixel (0, 1, Color.white);
lineTex.SetPixel (0, 2, new Color (1, 1, 1, 0));
lineTex.Apply ();
}
float angle = Vector3.Angle (pointB - pointA, Vector2.right) * (pointA.y <= pointB.y ? 1 : -1);
//Log (" a=" + pointA + " b=" + pointB + " A=" + angle);
float dx = pointB.x - pointA.x;
float dy = pointB.y - pointA.y;
float length = Mathf.Sqrt (dx * dx + dy * dy);
GUI.color = color;
GUI.matrix = Matrix4x4.TRS (new Vector3 (pointA.x, pointA.y, 0), Quaternion.identity, Vector3.one);
GUIUtility.RotateAroundPivot (angle, pointA);
GUI.DrawTexture (new Rect (0, 0, length, 1), lineTex);
GUI.color = savedColor;
if (destAnchor != null) {
DrawAnchor (pointB, angle, destAnchor);
}
if (srcAnchor != null) {
DrawAnchor (pointA, angle + 180, srcAnchor);
}
GUI.matrix = savedMatrix;
GUI.color = savedColor;
}