Question by
daviddickball · Mar 06, 2016 at 05:13 PM ·
particlesparticlesystemparticle emitter
How do you use emission.rate?
I keep getting warnings that emissionRate is deprecated, and I should use emission.rate instead. But the docs don't actually have any example of how this is used!
All I can find is this, which just says it's deprecated, but doesn't link to the new docs: http://docs.unity3d.com/ScriptReference/ParticleSystem-emissionRate.html
Comment
Answer by kusaeva · Jul 25, 2016 at 11:09 AM
try something like this:
public class ExampleClass : MonoBehaviour {
void Start() {
ParticleSystem ps = GetComponent<ParticleSystem>();
var emission = ps.emission;
var rate = emission.rate;
rate.constantMax = 20f;
emission.rate = rate;
}
}
Answer by Graphics_Dev · Mar 06, 2016 at 07:05 PM
Here is an example:
http://docs.unity3d.com/ScriptReference/ParticleSystem-emission.html
// Create a particle system
// At 2 and 4 secs the number of particles are changed to 50, then 100
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void Start() {
ParticleSystem ps = GetComponent<ParticleSystem>();
var em = ps.emission;
em.enabled = true;
em.type = ParticleSystemEmissionType.Time;
em.SetBursts(
new ParticleSystem.Burst[]{
new ParticleSystem.Burst(2.0f, 100),
new ParticleSystem.Burst(4.0f, 100)
});
}
}