Version: 5.5 (switch to 5.6b)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Method group is Obsolete

ParticleEmitter.particles

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete public var particles: Particle[];
Obsolete public Particle[] particles;

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.

var emitter: ParticleEmitter;

function Start() { emitter = GetComponent.<ParticleEmitter>(); }

function LateUpdate () { // extract the particles var particles = emitter.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 emitter.particles = particles; }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public ParticleEmitter emitter; void Start() { emitter = GetComponent<ParticleEmitter>(); } void LateUpdate() { Particle[] particles = emitter.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++; } emitter.particles = particles; } }