So I have a list that I want to go through and change some variables for attached ParticleSystems.
However, there are some GameObjects inside the list (they have to be in it) that Don’t have ParticleSystems components.
for(int i = 0; i < particlesList.Count; i++)
{
if(particlesList[i].GetComponent<ParticleSystem> () != null)
{
particlesList[i].particleSystem.startSize = particleSizes[i] * scaleFloat;
particlesList[i].particleSystem.startSpeed = particleSpeeds[i] * scaleFloat;
particlesList[i].transform.localScale = (particleScales[i] * scaleFloat);
}
}
With the if statement I get the out of range error which doesn’t make sense to me.
Without the if statement, It tells me I’m trying to access a component “ParticleSystem” that doesn’t exist on the GameObject. Then tells me to either check if it has one first, or create one for it.
Does anyone have any ideas?