Handles.DrawPolyLine 绘制多段线

static function DrawPolyLine (params points : Vector3[]) : void

Description描述

Draw a line going through the list of all points.

通过所有点的列表绘制线。

Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles.

注意:使用HandleUtility.GetHandleSize你可能希望有恒定屏幕大小的控制柄。

Handles.DrawPolyLine 绘制多段线

PolyLine that connects all the objects in the Scene View.
在场景视图多段线连接所有物体。

// Draw lines to the connected game objects that a script has.
// if the target object doesnt have any game objects attached
// then it draws a line from the Last checked object to 0,0,0
//绘制线用来连接带有脚本的物体
//如果目标物体没有任何物体被附加,然它绘制一条线从物体到0,0,0
@CustomEditor (ConnectedPolyLine)
class ConnectedPolyLineHandle extends Editor {

	var positions : Vector3[];

	function OnSceneGUI () {
		if(target.polyLineObjs.Length > 0)
		positions = new Vector3[target.polyLinesObjs.Length];
		for(var i = 0; i < target.polyLineObjs.Length; i++)
			if(target.polyLineObjs[i])
				positions[i] = target.polyLineObjs[i].transform.position;
			else
				positions[i] = Vector3.zero;
			Handles.DrawPolyLine(positions);
	}
}

And the script attached to this Handle:

该脚本附加到这个控制柄物体:

//ConnectedPolyLine.js

var polyLineObjs : GameObject[];
最后修改:2011年7月8日 Friday 19:55

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。