|
求大神帮忙,我写的脚本用来实现画线的简单功能,但是并没有看到画的线条。脚本也没有报错。
下面是具体的脚本:
using UnityEngine;
using System.Collections;
public class cs16 : MonoBehaviour {
public Material metarial;
void OnPostRender(){
if(!metarial){
Debug.LogError("please give metarial");
return;
}
GL.PushMatrix();
metarial.SetPass(0);
GL.LoadOrtho();
GL.Begin(GL.LINES);
GL.Color(Color.red);
DrawLine(0,0,200,100);
DrawLine(0,50,200,150);
DrawLine(0,100,200,200);
GL.End();
GL.PopMatrix();
}
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));
}
}
求大神指出问题在哪。。。。谢谢。。。。
|
|