console showing tons of obsolete API calls with the particlesystem
Assets\Scripts\TurretBase.cs(321,6): warning CS0618: 'ParticleSystem.enableEmission' is obsolete: 'enableEmission property is deprecated. Use emission.enabled instead.'
Is it possible to fix these in one line in .NET4.6?
Your code is calling obsolete methods/properties. You will need to change the code yourself, fortunately, the error messages are nice enough to tell you the replacement code.
that’s not what i’m asking, i’m asking if this can be done in 1 line instead of 3, because dotnet was updated to 4.6
ee.enabled = true;
particleSystem.emission = ee;```
Then you are asking the wrong question.
how so?
dotnet 4.6 can do things like gameObject?.GetComponent which effectively combines 2 lines in 1
I’m not sure it’s possible to do it in one line, since EmissionModule is a struct. Therefore particleSystem.emission
is always going to give you a copy of the EmissionModule which won’t help you change the one actually on the particle system. You could do it with an extra method though:
EmissionModule CopyWithEmission(EmissionModule original, bool emissionEnabled) {
EmissionModule copy = original;
copy.enabled = emissionEnabled;
return copy;
}
...
// Then here's the one-liner
particleSystem.emission = CopyWithEmission(particleSystem.emission, true);
Ok I thought dotnet4.6 had a shortcut to do that to structs.
I thought that too but the documentation doesn’t seem to mind https://docs.unity3d.com/ScriptReference/ParticleSystem.EmissionModule-rateOverTime.html
I tried your example and got some red. when I looked inside .emission it’s just a getter so particleSystem.emission =
isn’t possible.
enableEmission and WWW are not deprecated in 2020.2 so I might end up disabling 618 and be done with it.