Unity3D画线
2013-12-12 11:24
204 查看
using UnityEngine; using System.Collections; public class Line : MonoBehaviour { public Material mat; public Color color = Color.red; public Vector3 pos1; public Vector3 pos2; public bool isReady = false; void Start() { mat.color = color; } void Update() { if (Input.GetMouseButtonDown(0)) { pos1 = Input.mousePosition; } if (Input.GetMouseButtonUp(0)) { pos2 = Input.mousePosition; isReady = true; } } void OnPostRender() { if (isReady) { GL.PushMatrix(); mat.SetPass(0); GL.LoadOrtho(); GL.Begin(GL.LINES); GL.Color(color); GL.Vertex3(pos1.x/Screen.width, pos1.y/Screen.height, pos1.z); GL.Vertex3(pos2.x / Screen.width, pos2.y / Screen.height, pos2.z); GL.End(); GL.PopMatrix(); } } }
相关文章推荐
- 我心中的核心组件(可插拔的AOP)~第十二回 IoC组件Unity
- Visual Studio 2013 设置成为 Unity 3D 默认编辑器的方法
- [原]Unity手游之路 四 3d旋转-四元数,欧拉角和变幻矩阵
- [原]Unity手游之路<四>3d旋转-四元数,欧拉角和变幻矩阵
- Unity手游之路<四>3d旋转-四元数,欧拉角和变幻矩阵
- 【边玩边学Unity3d】做个小应用吧
- Unity 学习笔记——转自努力的小程序员 总结的很不错,学习了
- 【Unity3D】【NGUI】Tweens
- <Unity3D>Unity3D入门篇——第三讲 GUI控件(一)
- Unity3D研究院之Assetbundle的原理
- 【Unity3D】【NGUI】UICamera
- 【Unity3D】【NGUI】UILabel
- unity鼠标光标样式改变
- 【Unity3D】【NGUI】UILabel
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(21)-权限管理系统-跑通整个系统
- 【Unity3D】【NGUI】UICamera
- unity获取系统时间
- 关于unity计时问题
- unity3D发布webplayer,在webplayer中打开新的标签页
- unity3d的世界坐标转化成屏幕坐标