NGUI之使用UISprite画线
代码如下:
1 static void DrawLine(UISprite spriteLine, Vector3 start, Vector3 end) 2 { 3 Vector3 center = (start + end) / 2f; 4 Vector3 fromStart = end - start; 5 Vector3 horVector = Vector3.right; 6 Quaternion rot = Quaternion.FromToRotation(horVector, fromStart); 7 8 spriteLine.transform.localPosition = center; 9 spriteLine.transform.localRotation = rot; 10 spriteLine.width = Mathf.CeilToInt(fromStart.magnitude); 11 }