unity3D里把c#脚本改写成js脚本,如下程序如何改写成js脚本,写了半天都感觉有些问题
usingUnityEngine;usingSystem.Collections;publicclassCSdrawLine:MonoBehaviour{publicMa...
using UnityEngine;
using System.Collections;
public class CSdrawLine : MonoBehaviour {
public Material material;
void 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();
}
void DrawLine(float x1,float y1,float x2,float y2){
GL.Vertex(new Vector3(x1/Screen.width, y1/Screen.height, 0));
GL.Vertex(new Vector3(x2/Screen.width, y2/Screen.height, 0));
}
} 展开
using System.Collections;
public class CSdrawLine : MonoBehaviour {
public Material material;
void 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();
}
void DrawLine(float x1,float y1,float x2,float y2){
GL.Vertex(new Vector3(x1/Screen.width, y1/Screen.height, 0));
GL.Vertex(new Vector3(x2/Screen.width, y2/Screen.height, 0));
}
} 展开
展开全部
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));
}
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));
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询