I’m trying to emit particles with specific sprites from a Texture Sheet Animation. I have four sprites with the numbers 1, 2, 3 and 4 on them. These sprites are then added to the Texture Sheet Animation module:
I then emit four particles, each with one of these sprites:
System.Collections.IEnumerator Worker()
{
var anim = m_ParticleSystem.textureSheetAnimation;
var framesOnTexture = 4.0f;
while (true)
{
for (int n = 0; n < framesOnTexture; ++n)
{
anim.startFrame = (n / framesOnTexture);
ParticleSystem.EmitParams ep = new ParticleSystem.EmitParams();
ep.position = new Vector3(n, 0, 0);
m_ParticleSystem.Emit(ep, 1);
}
yield return new WaitForSeconds(1);
}
}
The loop creates four particles and sets the sprite via anim.startFrame
. I expected this to display 1234, but it shows 444 instead:
What am I doing wrong?
I’ve attached my test project in case that would help to understand what’s wrong.
ParticleSpriteTest.zip (57.1 KB)
@richardkettlewell 
Not at my machine atm so I can’t realy verify this but I do remember all kinds of behind-the-scenes shenanigans with the particle systems. I’m pretty sure that the anim struct’s properties make a direct call to the C++ side but just in case it’s a weird outlier, have you tried re-assigning the texture sheet animation back to the particle system after you make changes to it? Bit of a long shot but worth it nonetheless.
Hey, thanks for the reply!
I did, it’s read-only and causes a compile error 
By the way, assigning a number to anim.startFrame
does work. However, it seems that particles that have already been emitted pick up the new value when I assign anim.startFrame
, instead of retaining the frame that the existing particles were already at.
if you’re not against writing/modifying a shader, you could use vertex streams and just pass the index through a part of the emitParams you aren’t using.
Hey,
The Texture Animation module is applied at render-time, meaning particles do not cache any info from it when they are spawned.
So every time they are drawn, they read the current value of the start frame, etc.
@POOKSHANK 's suggestion could work for you. You could maybe use ps.SetCustomParticleData
instead of hacking the emitparams, but, i’m not sure if you can know which array indices you just emitted into.
Or, if you use mesh particles instead (using the same quad mesh in all 4 entries) you can tell the texture sheet module to map the mesh index to texturesheet frame. which is a complete hack, and limits you to only 4 items, but, could work.
Sorry I don’t have a great answer for this!