Legacy Documentation: Version 5.5
LanguageEnglish
  • C#
  • JS

Script language

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

ParticleSystem.subEmitters

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

Switch to Manual
public var subEmitters: ParticleSystem.SubEmittersModule;
public ParticleSystem.SubEmittersModule subEmitters;

Description

Access the particle system sub emitters module.

Particle system modules do not need to be reassigned back to the system; they are interfaces and not independent objects.

no example available in JavaScript
using UnityEngine;
using System.Collections;

// A simple example showing access. public class ExampleClass : MonoBehaviour {

public ParticleSystem mySubEmitter;

void Start() { ParticleSystem ps = GetComponent<ParticleSystem>(); var sub = ps.subEmitters; sub.enabled = true; sub.AddSubEmitter(mySubEmitter, ParticleSystemSubEmitterType.Death, ParticleSystemSubEmitterProperties.InheritNothing); } }
no example available in JavaScript
using UnityEngine;

// An example showing how to create 2 particle systems; one as a sub-emitter. public class SubEmitterDeathExample : MonoBehaviour { void Start () { // A simple particle material with no texture. Material particleMaterial = new Material(Shader.Find("Particles/Alpha Blended Premultiply"));

// Create a green particle system. var rootSystemGO = new GameObject("Particle System"); rootSystemGO.transform.Rotate(-90, 0, 0); // Rotate so the system emits upwards. var rootParticleSystem = rootSystemGO.AddComponent<ParticleSystem>(); rootSystemGO.GetComponent<ParticleSystemRenderer>().material = particleMaterial; var mainModule = rootParticleSystem.main; mainModule.startColor = Color.green; mainModule.startSize = 0.5f;

// Create our sub-emitter and set up bursts. var subSystemGO = new GameObject("Particle System"); var subParticleSystem = subSystemGO.AddComponent<ParticleSystem>(); subSystemGO.GetComponent<ParticleSystemRenderer>().material = particleMaterial; var subMainModule = subParticleSystem.main; subMainModule.startColor = Color.red; subMainModule.startSize = 0.25f; var emissionModule = subParticleSystem.emission; emissionModule.SetBursts(new ParticleSystem.Burst[] { new ParticleSystem.Burst(0.0f, 10) }); // We will emit 10 particles upon death.

// Set up the sub-emitter. subSystemGO.transform.SetParent(rootSystemGO.transform); var subEmittersModule = rootParticleSystem.subEmitters; subEmittersModule.enabled = true; subEmittersModule.AddSubEmitter(subParticleSystem, ParticleSystemSubEmitterType.Death, ParticleSystemSubEmitterProperties.InheritNothing); } }