纳金网
标题:
画直线和斜线
[打印本页]
作者:
狂风大尉
时间:
2014-6-27 00:09
标题:
画直线和斜线
var mat : Material;
private var startVertex : Vector3;
private var mousePos : Vector3;
startVertex = Vector3(0,0,0);
function Start () {
print("start");
}
function Update () {
mousePos = Input.mousePosition;
// Press space to update startVertex
if(Input.GetKeyDown(KeyCode.Space)){
startVertex = Vector3(mousePos.x/Screen.width, mousePos.y/Screen.height, 0);
}
}
function OnPostRender() {
if (!mat) {
Debug.LogError("Please Assign a material on the inspector");
return;
}
GL.PushMatrix();
mat.SetPass(0);
GL.LoadOrtho();
GL.Begin(GL.LINES);
GL.Color(Color.red);
GL.Vertex(startVertex);
GL.Vertex(Vector3(mousePos.x/Screen.width, mousePos.y/Screen.height, 0));
GL.End();
GL.PopMatrix();
}
复制代码
作者:
hyui
时间:
2014-6-27 00:38
Good to know !
作者:
wucnj
时间:
2014-6-27 11:10
感谢分享!!!
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5