Unity3d学习笔记(一)Particle Layer
2014-01-08 16:47
232 查看
今天简单看了下一个比较老的Partical Tutorial的例子,感觉Unity的粒子系统还是较为先进的,以前GB连长条形粒子都做不到,真心痛苦……但GB可以直接在Max里面预览效果,而且可以使用Max本身的粒子系统和动画工具,这样的设计思路即使现在看来也是非常先进的,可惜换了下家之后一直不死不活……商业化的恶果,不提了。
废话说完,接下来记笔记:
在使用旧有的Legacy Particle System时,Particle Renderer的Materials Size参数可以设置成大于1使得同一个粒子系统使用多种材质,但是似乎排序是id越低的排在越后面,比如Element 0就排在Element 1的下面,这个和新的Shuriken粒子系统里面的Sorting Fudge正好反过来,后者是数字越低排在越前(这里的前后都是指在摄像机空间内的前后关系)
旧有的Legacy Particle System当多个粒子系统重合的时候,自动排序会变得混乱,这时候可以采用一个Particle Layer的强制排序脚本挂在物体上,是个javascript,不知道编译之后效率如何,代码如下:
To get the script into the project, click on the Create menu in the Project pane and select JavaScript from the
menu. Name your script "ParticleLayer" and then open it and paste the code into it. Save it, return to Unity and wait for it to compile. (Shown by a little rotating thing in the lower right corner. With just this script it should be almost instant) Once it
is done, drag the script from the Project pane to the Hierarchy and onto your fire particle emitter that is a child of "Fire Group". Then select the object you just dragged the script onto and set Layer Height to 0.5. This will make the fire always 0.5 meters
closer to the camera then it normally would be.
参数只要大于0估计就差不多了,不过对于烟雾和火焰的制作,烟雾和火焰发射器之间的间距肯定要大于这个数值,不然从顶上或者底下看起来就不对了。
废话说完,接下来记笔记:
在使用旧有的Legacy Particle System时,Particle Renderer的Materials Size参数可以设置成大于1使得同一个粒子系统使用多种材质,但是似乎排序是id越低的排在越后面,比如Element 0就排在Element 1的下面,这个和新的Shuriken粒子系统里面的Sorting Fudge正好反过来,后者是数字越低排在越前(这里的前后都是指在摄像机空间内的前后关系)
旧有的Legacy Particle System当多个粒子系统重合的时候,自动排序会变得混乱,这时候可以采用一个Particle Layer的强制排序脚本挂在物体上,是个javascript,不知道编译之后效率如何,代码如下:
// ParticleLayer.js var layerhieght = 0.00; private var position : Vector3; position = transform.localPosition; function Update () { object = Camera.main.gameObject; vector = object.transform.position - transform.position; if(transform.parent && (vector.magnitude > layerhieght || layerhieght < 0.00) ) transform.position = transform.parent.TransformPoint(position) + vector.normalized * layerhieght; }
To get the script into the project, click on the Create menu in the Project pane and select JavaScript from the
menu. Name your script "ParticleLayer" and then open it and paste the code into it. Save it, return to Unity and wait for it to compile. (Shown by a little rotating thing in the lower right corner. With just this script it should be almost instant) Once it
is done, drag the script from the Project pane to the Hierarchy and onto your fire particle emitter that is a child of "Fire Group". Then select the object you just dragged the script onto and set Layer Height to 0.5. This will make the fire always 0.5 meters
closer to the camera then it normally would be.
参数只要大于0估计就差不多了,不过对于烟雾和火焰的制作,烟雾和火焰发射器之间的间距肯定要大于这个数值,不然从顶上或者底下看起来就不对了。
相关文章推荐
- Unity3d学习笔记
- Unity3D学习笔记10:Unity调用DLL
- Unity3D学习笔记——Unity3D的窗口布局
- unity3d学习笔记(九)--NGUI制作英雄和怪物的头像和血条
- unity3d学习笔记(十九)--ngui制作人物头顶的头像和血条
- Unity3D学习笔记【01】
- unity3d学习笔记(二十)--利用JSON读取和保存游戏数据
- Unity3D学习笔记(三)Unity的C#基础
- 【Unity3d学习笔记】基础引擎操作
- Unity3D学习笔记《Roll-a-Ball》一
- Unity3D学习笔记(五)湖泊与瀑布
- Unity3D学习笔记(二十一)导入WOW动画不完美修复方案
- Unity3D学习笔记(9)—— 粒子光环
- Unity3D学习笔记——NGUI之UIToggle
- Unity3D学习笔记(2)
- Unity3d学习笔记 var 关键字
- Unity3d学习笔记
- unity3d学习笔记1
- unity3d学习笔记(八)--NGUI制作游戏界面
- Unity3D学习笔记——Camera绕着物体旋转