Change Particle StartColor 'Random Between Two Colors'

I’ve got a ParticleSystem that is activated when the player dies, my player can be various colours during the game so I want the particles to match its current colours

I know I can change the start colour with the following code:

this.particleSystem.startColor =;

This works, however I’m using the ‘Random Between Two Colors’ option and that code only changes the first colour. I need to be able to change both colors in code, and I’m totally stumped on how to do it. I’ve searched Unity answers but haven’t been able to find an answer.

Hope that makes sense, any help is really appreciated

I don’t think you can do it in runtime, but you can do it from an Editor script. See the answer on this one: