新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Unity實現(xiàn)繪制線斷二-----用GL畫矩形線框-創(chuàng)新互聯(lián)
今天有點時間,才記起來上一次寫的畫線框,接著上一節(jié)畫線,我們這節(jié)來看一下GL畫線
直接上代碼
using UnityEngine; using System.Collections; using System.Collections.Generic; public class joint{ public Vector3 org; public Vector3 end; } public class example : MonoBehaviour { Event e; private Vector3 orgPos; private Vector3 endPos; private bool canDrawLines = false; ArrayList posAL; ArrayList temppos; public Material lineMaterial; public ListPos = new List (); void Start() { temppos=new ArrayList(); posAL=new ArrayList(); } void Update() { if(Input.GetMouseButtonUp(0)) { canDrawLines = true; } if(e.type!=null &canDrawLines) { if(e.type == EventType.MouseDown) { orgPos=Input.mousePosition; } if(e.type==EventType.MouseUp) { endPos=Input.mousePosition; Pos.Add (endPos); for (int i = 0; i < Pos.Count-1; i++) { Vector3 p = Pos [i]; } GLDrawLine (orgPos, endPos); orgPos = endPos; } } } void GLDrawLine(Vector3 beg ,Vector3 end ) { if(!canDrawLines) return; GL.PushMatrix (); GL.LoadOrtho (); beg.x=beg.x/Screen.width; end.x=end.x/Screen.width; beg.y=beg.y/Screen.height; end.y=end.y/Screen.height; joint tmpJoint = new joint(); tmpJoint.org=beg; tmpJoint.end=end; posAL.Add(tmpJoint); lineMaterial.SetPass( 0 ); GL.Begin( GL.LINES ); GL.Color( new Color(1,1,1,1f) ); for(int i= 1;i 另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
網(wǎng)頁標題:Unity實現(xiàn)繪制線斷二-----用GL畫矩形線框-創(chuàng)新互聯(lián)
鏈接URL:http://www.ef60e0e.cn/article/jhpdg.html