Error when using texture animation in particle system

I get the error:

psTemp.sheetIndex _>= 0.0f && psTemp.sheetIndex *<= 1.0f*_

in the console when I have a particle system with a texture animation. I can get rid of the error by switching off texture animation or by not making changes to the particles in the FixedUpdate function - either works. All I’m doing in fixed update is letting the particles roam free for a few seconds, then gathering them into a pot:
void FixedUpdate() {
bool particlesModified = false;
* psCoins.GetParticles(coins);*
* if (!psCoins.IsAlive()) {*
* return;*
* }*

* for (int i = 0; i < coins.Length; i++) {*

_ if (coins*.lifetime < 0f) {
continue;
}*_

* //Time to animate the coin going into the jar?*
_ if (coins*.lifetime < remainingLifeToJar) {
//Animated - lerp to the target*

* particlesModified = true;*_

coins.position = Vector3.Lerp(pot.transform.position, coins_.position, coins*.lifetime / remainingLifeToJar);
coins.velocity = Vector3.zero;
}
}*_

* if (particlesModified) {*
* psCoins.SetParticles(coins, coins.Length);*
* }*
}
The fact the error is talking about sheetIndex makes me think it probably is related to the texture animation system, but I have no idea how this is happening or why. There’s no stack trace, and no documentation related to this error.

So I found the answer. It’s almost certainly because when I call SetParticles I’m passing the size of the coins array as the second parameter, rather than the number of alive particles.

Line 4 should get the number of alive particles:

int liveCount = psCoins.GetParticles(coins);

And line 26 should use that value, not the size of the array passed in:

psCoins.SetParticles(coins, liveCount);