unity3D里把c#脚本改写成js脚本,如下程序如何改写成js脚本,写了半天都感觉有些问题

2024-11-23 22:20:09
推荐回答(1个)
回答1:

public var material : Material;

function OnPostRender(){
if(!material){
Debug.LogError("ss");
return;
}
material.SetPass(0);
GL.LoadOrtho();
GL.Begin(GL.LINES);
DrawLine(0,0,200,100);
DrawLine(0,50,200,150);
DrawLine(0,100,200,200);
GL.End();

}

function DrawLine(var x1:float,var y1:float,var x2:float,var y2:float){
GL.Vertex(new Vector3(x1/Screen.width, y1/Screen.height, 0));
GL.Vertex(new Vector3(x2/Screen.width, y2/Screen.height, 0));
}