Search code examples
c#unity-game-engineparticle-systemdeprecation-warning

Can't use c# particleSystem property anymore?


I was able before to use in Visual Studio C# code,

particleSystem.SetParticles(points, points.Length);

but now it gives me an error. Did the syntax change? Do I have to use

GetComponent<ParticleSystem>().SetParticles(points, points.Length);

now? My VS project (using Unity here) does not display my particles anymore but I have not found any other syntax I could/should be using. Is this correct, and do I have some other error? Or is this incorrect? Thanks.


Solution

  • Base on the relevant Unity documentation, this is another property that has been recently (since version 5.4.0) deprecated.

    So yes, you will now have to use GetComponent<ParticleSystem>() instead to get a reference to the particle system - and you'll probably want to cache that reference in a variable in the Awake() method in the event that you need to frequently make use of it.