U3D目前发现的一个画线最好的工具。
画一条直线
// Make Vector2 array; in this case we just use 2 elements...
var linePoints = [Vector2(0, Random.Range(0, Screen.height)), // ...one on the left side of the screen somewhere
Vector2(Screen.width-1, Random.Range(0, Screen.height))]; // ...and one on the right
// Make a VectorLine object using the above points and the default material, with a width of 2 pixels
var line = new VectorLine("Line", linePoints, null, 2.0);
// Draw the line
Vector.DrawLine(line);
// Draw a line from the lower-left corner to the upper-right corner
Vector.SetLine (Color.white, Vector2(0, 0), Vector2(Screen.width-1, Screen.height-1));
以上可以简单画一条线,有点像Debug.DrawLine()那样就画一条细细的线。同理Debug.DrawRay()也在这里有Vector.SetRay()也可以,但是SetLine可以用Vector2和Vector3的点,但是SetRay只能是Vector3世界中的点。
Vector.SetRay3D()
用以上画即可。
VectorLine SetLine (Color color, float time, params Vector2[] points)
以上方法第二个参数可以传一个time进去,多少s会消失掉。
myLine.active = false;
myLine.active = true;
那么关闭时候,使用drawLine将没有作用。
画点
和VectorLines一样,可以new VectorPoints()创建一个点集对象,和VL一样,可以设置颜色,属性选项等。
然后用Vector.DrawPoints(myPoints);就可以画出来了,基本上和vl的概念是一样的。
ADD+Utilities*****
在Vector类里面,提供了很多额外的实用工具方法给我们,一般有Set和Get以及Make开头。
例如SetColor和SetColors……等
标星号,表示这个类里面提供的这些实用工具除了画点和线,可以制造我们常用的曲线和方框等。。
ADD+VectorManager
// Make a Vector3 array that contains points for a cube that's 1 unit in size
var cubePoints = [Vector3(-0.5, -0.5, 0.5), Vector3(0.5, -0.5, 0.5), Vector3(-0.5, 0.5, 0.5), Vector3(-0.5, -0.5, 0.5), Vector3(0.5, -0.5, 0.5), Vector3(0.5, 0.5, 0.5), Vector3(0.5, 0.5, 0.5), Vector3(-0.5, 0.5, 0.5), Vector3(-0.5, 0.5, -0.5), Vector3(-0.5, 0.5, 0.5), Vector3(0.5, 0.5, 0.5), Vector3(0.5, 0.5, -0.5), Vector3(0.5, 0.5, -0.5), Vector3(-0.5, 0.5, -0.5), Vector3(-0.5, -0.5, -0.5), Vector3(-0.5, 0.5, -0.5), Vector3(0.5, 0.5, -0.5), Vector3(0.5, -0.5, -0.5), Vector3(0.5, -0.5, -0.5), Vector3(-0.5, -0.5, -0.5), Vector3(-0.5, -0.5, 0.5), Vector3(-0.5, -0.5, -0.5), Vector3(0.5, -0.5, -0.5), Vector3(0.5, -0.5, 0.5)];
// Make a line using the above points and material, with a width of 2 pixels
var line = new VectorLine("Cube", cubePoints, Color.white, lineMaterial, 2.0);
// Make this transform have the vector line object that's defined above
// This object is a rigidbody, so the vector object will do exactly what this object does
VectorManager.ObjectSetup (gameObject, line, Visibility.Dynamic, Brightness.None);