找回密码
 立即注册
查看: 4681|回复: 60

[脚本] 求大神帮忙,我写的脚本不能实现画线

[复制链接]
发表于 2013-8-14 16:35 | 显示全部楼层 |阅读模式
求大神帮忙,我写的脚本用来实现画线的简单功能,但是并没有看到画的线条。脚本也没有报错。
下面是具体的脚本:
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));
               
        }
}
求大神指出问题在哪。。。。谢谢。。。。



发表于 2017-4-12 08:57 | 显示全部楼层
好帖就是要顶
发表于 2017-4-12 08:31 | 显示全部楼层
难得一见的好帖
发表于 2017-4-12 09:14 | 显示全部楼层
说的非常好
发表于 2017-4-12 08:47 | 显示全部楼层
很好哦
发表于 2017-4-12 09:13 | 显示全部楼层
LZ真是人才
发表于 2017-4-14 10:01 | 显示全部楼层
很不错
发表于 2017-4-14 09:55 | 显示全部楼层
顶顶多好
发表于 2017-4-14 09:21 | 显示全部楼层
真心顶
发表于 2017-4-14 09:29 | 显示全部楼层
说的非常好
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-2 00:56 , Processed in 0.117119 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表