有没有什么好的unity3d gl 画线 粗细的画线插件

Unity3d(84)
http://blog.csdn.net/g__dragon/article/details/
Vectrosity是一个很方便的画线插件,用它我们可以画出2D,3D,贝塞尔,圆,椭圆等各种线条图案。
:链接:&&密码: uesn
首先导入Vectrosity,导入后是这样的
打开Sences,看第一个Demo
Vectrosity插件采用的脚本都是用JS编写的,在第一个Demo中有三个脚本
,全部运行的效果是这样的。
这里我改为C# 的写法来书写脚本。
第一种最简单的方法画线:
void Start(){
VectorLine.SetLine(Color.white, new Vector2(0, 0), new Vector2(Screen.width - 1, Screen.height - 1));}
VectorLine类是Vectrosity的最基础的类,而SetLine是它的静态方法。
static VectorLine Setline(Color color,float time=Mathf.Infinity,Vector2[]/Vector[3] params points )
第一个参数设置线的颜色,第二个设置它显示的时间,默认可以不设置,第三个设置它线上的点的二维数组或三维数组用于链接二维点坐标或三维点坐标。
第二种方法:
void Start(){
Vector2[] linePoints= {new Vector2(0, Random.Range(0, Screen.height)),&&&// 第一个点在屏幕最左边
&&&&&&&& new Vector2(Screen.width-1, Random.Range(0, Screen.height))};&// 第二个在屏幕右边,高度都随机&
// 定义一个 VectorLine 对象,名字是“Line” 使用linePoints数组内的点, 并且使用默认材质, 线的宽度是2像素
VectorLine line = new VectorLine(&Line&, linePoints, null, 2.0f);
// 画出这条线
line.Draw();
这是Vectrosity插件最常用的方法,先定义一个二维或三维数组,用于保存线内包含的点,然后再定义一个VectorLine对象 就是一个线对象,参数已解释,最后调用Draw方法画线。
用Vectrosity画线,就是这么简单。。。
[csharp]&&
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:67364次
积分:3347
积分:3347
排名:第7561名
原创:215篇
转载:364篇
评论:82条
文章:38篇
阅读:6454
(25)(80)(71)(18)(9)(20)(107)(7)(9)(28)(11)(12)(8)(13)(58)(34)(40)(10)(22)扫一扫,访问微社区
后使用快捷导航没有帐号?
签到成功!您今天第{todayrank}个签到,签到排名竞争激烈,记得每天都来签到哦!已连续签到:{constant}天,累计签到:{days}天
当前位置: & &
本站内容来自互联网,仅用于学习,禁止商用,请支持正版。
版权归作者所有,如果侵犯您的权益请联系我们,联系本站删除。
昨天&17:34
昨天&21:24
本帖最后由 scma 于
00:46 编辑
由于网站限制,本日的上传附件数量已达到上限, ...
在Animator里创建了一个Shot变量,我怎么知道在哪里可以改变它?我看的是官方教程秘密行动的代码。里边的机器人动画,添加了一个Shot的变量 ...
Adam Exterior Environment
本帖最后由 MemoryC 于
20:52 编辑
在上一篇中,我们分享了如何使用使用C#在Unity3D里面调用Android里的系统图库,并获 ...
我获取了两个点,一个鼠标按下的点,一个鼠标滑动的点,然后比较他们的x,y,然后主角做出相应的转向(面向上、下、左、右),例如:我向右滑 ...福利来啦!!史上最简单效果最好的unity3D分辨率适应插件及教程!(更新)
精华热门加亮
&注意:看到还有好多人在关注本帖,本着对大家负责的态度,我建议大家不需要再用此分辨率适应方案了,我也有将近1年多没更新了。此分辨率适应是在NGUI还没有好的分辨率适应方案、还不存在UGUI的情况下写出来的分辨率适应方案。现在NGUI、UGUI的分辨率适应方案跟此方案差不多,并且功能做的更好。所以大家可以用UGUI或者NGUI的分辨率适应方案。谢谢大家的关注。(更新)
---------------------------------------------------------------------------------------------------------------
你还在用NGUI的分辨率适应方式吗?你还在用2DTooKit分辨率适应方式吗?如果你还用那么说明你已经OUT啦!
下面我来讲讲这几天编写的一套分辨率适应方式,适用于任何分辨率,并且简单易上手,还支持横屏和竖屏,只需要你填写最合适你UI的分辨率,当你切换到其他分辨率的时候UI自动适应(包括位置和大小),而且不会有任何UI拉伸现象。
&
第一步:首先你要把MyAnchorCamera这个脚本拖到你摄像机上,然后你会看到你的摄像机上附加了这个脚本,并且这个脚本下面有一些参数
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_89d92f47a312da4.png');" />
&
&
下面我来教大家怎么设置这些参数:
Mode:最开始你要选择你要适应的是横屏还是竖屏(这个很重要),不同模式他的适应方式不一样,默认的是竖屏模式(Tall)。
Scale:这个参数不需要你设置,这个参数会根据你当前的分辨率设置好的。
suirableUI_width:这个参数很重要,你需要自己填写最适合你UI大小、位置的分辨率的宽,也就是你在哪个分辨率下编辑游戏的UI的大小位置最合适就填写哪一个分辨率。默认参数是0,当然你不填的话,你切换分辨率的时候你的UI大小不会改变的哈。
suirableUI_height:同上
所以你最开始要做的事情就是要把Mode和suirableUI_width、suirableUI_height三个参数填好(记得一定要先填哈)!
&
&
现在开始实战演练,我是在854 * 480分辨率横屏模式下进行编辑的(大家请注意分辨率和UI位置哈):
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_a83aa.png');" />726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_da22e9ee04235c5.png');" />
&
&
第二步:点击刚才附加到摄像机上那个脚本中的Create Anchor按钮
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_3ad6ca82bcb228d.png');" />
&
&
然后你会发现在摄像机下面会创建一个空对象Anchor,在这个对象上面会有一个脚本,这个脚本的作用其实就是对UI进行固定,也就是相当于对UI进行描点。
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_bcb7277c2acc027.png');" />726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_51b65.png');" />
&
现在来说说这个空对象上面的MyUIAnchor这个脚本中的参数:
Anchor:这个参数是可选参数,里面有13中方法,分别多顶端的左、中、右,对中间的左、中、右,对底端的左、中、右,对四个角进行描点(也就是固定UI的位置)
offset:是UI的偏移变量,对UI位置进行微调参数
&
&
第三步:我们对UI进行描点(位置固定),我们创建5个Anchor空对象
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_932a7.png');" />
&
&
然后改变每一个Anchor的模式,然后改一个我们能辨认的名字(记得一定要先选择模式哦,不然UI位置不好控制哈)
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_e1d0.png');" />726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_b32e35.png');" />
&
这些完成以后就把你要固定的UI拖到上面选好模式的空对象下面
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_aad.png');" />726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_a11.png');" />
&
&
&
&
下面我们来看看分辨率适应的效果如何(注意UI的位置和大小哦,我是在854 * 480分辨率下进行适应的哦):
480 * 320:
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_5c2edc53d5d6775.png');" />
&
&
800 * 480:
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_b82b6a813a7b279.png');" />
&
&
1024 * 600:
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_d0b8b70e6ad2563.png');" />
&
&
&
960 * 680:
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_ba3d5a.png');" />
&
&
&
1280 * 800:
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_2e5620.png');" />
&
&
&
&
1024 * 768:
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_f1e03a44a9dcf98.png');" />
&
&
&
&
最后来一个不规则的分辨率910 * 613:
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_08fbf524ebbe09e.png');" />
&
&
&
&
&
木有了,完成了,有木有很简单,有木有!
当然作为福利,附件里面还有一个背景填充脚本!把BKAnchor这个脚本放到你要填充整个摄像机的背景图片上它会自动的帮你把摄像机填充满,注意背景会有一定程度的拉伸变形哈!
(先前那个附件BKAnchor脚本整掉了一行代码,现在补上,大家看看还有没有错,这个脚本要在有MyAnchorCamera这个脚本的前提下才能生效哈)
有问题或者改进建议、经验交流请加unity3D技术交流群:3112035
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &
& & & & & & & & & & & & & &———— &大红花
版本1.0.1(1.增加了一个自动适应模式,能够按照变化最大的分辨率进行适应;2.去除了几个重复的描边方法;3.增加场景中若有多个Camera情况下可以分别适应不同Camera的功能 4.增加了显示当前分辨的开关,便于调试 5.修改了若干bug)
版本2.0(增加NGUI的层级分辨率适应:如果用的是NGUI的层级关系,那么只需要启用isNGUIHierarchy变量即可,其他的适应请看上面的教程)
726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/1308/thread/2_956f1cd1.png');" />726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/1308/thread/2_4da7dbdd.png');" />
版本2.1.0(1、修复了摄像机剪裁不准确的bug 2、完善了适应不同摄像机的机制 3、去除了旧的背景适应机制,增加了新的背景适应机制,背景适应更加准确,只需要把“MyBKAnchor”脚本拖到背景图片的对象上然后选择适应的类型即可)
要评论请先&或者&
希望对大家有用
下来先试试 ,倘若很好。我会加倍祝福楼主的。
分享知识的人越来越少了,赞一个!
不错学习了。
楼主,看下呗。。。报错呀726 || this.offsetHeight>700){if(this.offsetWidth/726 > this.offsetHeight/700){this.width=726;}else{this.height=700;}}" style="max-width:726max-height:700" title="点击查看原图" onclick="if(this.parentNode.tagName!='A') window.open('/forum/attachment/Mon_5_104eebb48d52da9.png');" />
& 火速占楼
:楼主,看下呗。。。报错呀[附件] ( 14:35) 这个脚本不要乱用 可能那儿木有考虑到
& 楼主,看不到任何的图片啊。请教一下Vectrosity画线插件_unity3d吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:57,736贴子:
请教一下Vectrosity画线插件收藏
因为最近用到画线,所以用Vectrosity插件来试试。但发现 官方给出 的 所有 demo 都是
js写的,我是想用C#。难道要我 一个个 改写一遍吗?请问 各位 有没有 c# 版本的 demo下载,或者你们是 如何 学的呢?
&京东&好物低价,火力全开,11-11来京东,全网嗨&GO&!「狂抢72小时」,认真购物,买点好的!unity3d-京东11-11,&尖&货云集,横扫全网底价,这个11-11认真购物,只对自己好!
楼主现在有没有C#版的
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或

我要回帖

更多关于 unity3d 鼠标画线 的文章

 

随机推荐