Returns a copy of all particles and assigns an array of all particles to be the current particles.
// Attach this script to an existing particle emitter. 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 emitter particleEmitter.particles = particles; }
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; } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def LateUpdate() as void: particles as (Particle) = particleEmitter.particles i as int = 0 while i < particles.Length: yPosition as float = (Mathf.Sin(Time.time) * Time.deltaTime) particles[i].position += Vector3(0, yPosition, 0) particles[i].color = Color.red particles[i].size = (Mathf.Sin(Time.time) * 0.2F) i++ particleEmitter.particles = particles