I am trying to turn off multiple Particle Emitters in the children of an object at the same time using an array. I will be using the same code to turn them back on later, but I can't get either to work.
Here is the code I am using:
var particleEmitters : ParticleEmitter[];
particleEmitters = gameObject.GetComponentsInChildren(ParticleEmitter) as ParticleEmitter;
for (var emitters : ParticleEmitter in particleEmitters)
{
emitters.emit = false;
}
I get the following error message:
Cannot convert 'UnityEngine.ParticleEmitter' to 'UnityEngine.ParticleEmitter[]'.
Does this mean it is impossible to use an array for Particle Emitters? Or do I have something else set up incorrectly?
the code seems completely okay to me!
– Ashkan_gc