Unity3D实现粒子光环效果
参考效果: http://i-remember.fr/en
基本思路如下
1. 使用unity3d自带的粒子系统
2. 为圆环设置最大半径maxR和最小半径minR
3. 使用x=R*sin(angle), y=R*cos(angle)来计算每个粒子的坐标
4. 将粒子数组设置到选定的粒子系统中
下面说说具体步骤
一.
设置Main Camera的投影方式为正交投影,将背景设置为黑色,方便观察粒子效果
接着新建一个Empty GameObject,用来挂载粒子系统,注意这个空物体要放在摄像机的投影范围内,为这个物体添加粒子系统,并且按图中方式设置粒子系统
主要是要将Looping选项和Play OnAwake选项去掉,同时把Emission Rate设为0
二.
新建C#脚本,用来控制粒子系统
定义点结构,用来表示粒子的坐标信息
public class Point {
public float angle;
public float radius;
private float x = 0.0f;
private float y = 0.0f;
public void Cal() {
float temp = angle / 180.0f * Mathf.PI;
y = radius * Mathf.Sin(temp);
x = radius * Mathf.Cos(temp);
}
public Point(float angle, float radius) {
this.angle = angle;
this.radius = radius;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
}
三.
声明粒子系统和粒子系统的相关参数
private ParticleSystem particleSystem;
//粒子数组
private ParticleSystem.Particle[] particleArray;
//粒子坐标集合
private Point[] points;
//颜色梯度
public Gradient grad;
//控制透明度的变化
private GradientAlphaKey[] gradAplp;
//控制颜色的变化
private GradientColorKey[] gradCol;
//粒子参数
public int count = 1000;
public