The current solution that works is

gameObject.GetComponent<ParticleSystem>().startSize = 1

but VStudio 2017 reports that startSize is obsolete and should be replaced with main.startSize. But when I do that, I get an error:

Cannon modify the return value of ParticleSystem.main because it is not a variable.

So how should I set the start size value?

1 Answers

Rishaan Gupta On Best Solutions

ParticleSystem.main returns a struct, not a class. Struct's are value types, in that when you move them around their values are copied into a new object. You have to first store the returned value in a variable then modify it.

var main = particleSystem.main;
main.startSize = 1;