- Home /
Question by
siddharth3322 · Nov 20, 2019 at 04:51 PM ·
particlesparticlesystemparticle emitterparticleemitter
Particle Emitter Deprecated
I have an old project which contains ParticleEmitter implemented.
public ParticleEmitter Spawn(ParticleEmitter prefab,
Vector3 pos, Quaternion rot)
{
// Instance using the standard method before doing particle stuff
Transform inst = this.Spawn(prefab.transform, pos, rot);
// Can happen if limit was used
if (inst == null) return null;
// Make sure autodestrouct is OFF as it will cause null references
var animator = inst.GetComponent<ParticleAnimator>();
if (animator != null) animator.autodestruct = false;
// Get the emitter
var emitter = inst.GetComponent<ParticleEmitter>();
emitter.emit = true;
this.StartCoroutine(this.ListenForEmitDespawn(emitter));
return emitter;
}
So what I require to change to make this work?
Comment
Answer by TreyH · Nov 20, 2019 at 04:58 PM
Those components are now accessed with modules. From the .emission docs
ParticleSystem ps = GetComponent<ParticleSystem>();
var em = ps.emission;
em.enabled = true;