ParticleEmitter.particles 粒子列表
var particles : Particle[]
Description描述
Returns a copy of all particles and assigns an array of all particles to be the current particles.
返回全部粒子的一个拷贝,分配所有粒子的数组到当前的粒子。
Note that after modifying the particles array you must assign it back to the particleEmitter to see the change. Particles with energy of zero or less will be killed when assigning the particles. Thus when creating a complete new particle array, you need to set the energy of all particles explicitly.
注意:在修改粒子数组之后,你必须将它赋回粒子发射器才能看到改变。能量为零或者更少的粒子在赋值粒子的时候将会被销毁。因此当创建一个完整的新粒子数组时,你需要清楚地设定所有粒子的能量。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void LateUpdate() {
Particle[] particles = particleEmitter.particles;
int i = 0;
while (i < particles.Length) {
float yPosition = Mathf.Sin(Time.time) * Time.deltaTime;
particles[i].position += new Vector3(0, yPosition, 0);
particles[i].color = Color.red;
particles[i].size = Mathf.Sin(Time.time) * 0.2F;
i++;
}
particleEmitter.particles = particles;
}
}
// Attach this script to an existing particle system.
// 将这个脚本赋予一个存在的粒子系统。
function LateUpdate () {
// extract the particles
// 提取粒子
var particles = particleEmitter.particles;
for (var i = 0; i < particles.Length; i++) {
// Move the particles up and down on a sinus curve
// 按照正弦曲线上下移动粒子
var yPosition = Mathf.Sin (Time.time) * Time.deltaTime;
particles[i].position += Vector3 (0, yPosition, 0);
// make the particles red
// 使粒子为红色
particles[i].color = Color.red;
// modify the size on a sinus curve
// 按照正弦曲线修改粒子尺寸
particles[i].size = Mathf.Sin (Time.time) * 0.2;
}
// copy them back to the particle system
// 将它们复制回粒子系统
particleEmitter.particles = particles;
}
最后修改:2011年1月23日 Sunday 13:17