Unable to dynamically change material attributes of ParticleSystemRenderer in custom script

I’m trying to create a particle system that I need to be able to fade in and out at different points in my game.
I created a custom material that’s applied to the particle system which contains an intensity value that I dynamically change through a custom script.

However it’s not working. If print the value of the intensity attribute to the console it does change but it’s not being applied to the particles. Whenever I access the material of any other renderer object (i.e MeshRenderer, SpriteRenderer) I’m able to change the attributes values.

Any help would be appreciated. Thanks!

Check the docs here:

You must copy the material out, modify it and assign it back to the renderer at least once, then you will be manipulating the material you expect.

Thanks for pointing out the docs however I have tried this with no luck. Upon initialization of the script I’ve copied the renderer’s material, then in a separate function modified it and assigned it back to the renderer, but it stays the same.

Is this perhaps something to do with me using a custom shader and material for the particle system? I don’t see why that would effect it although I did notice that after applying the custom material I wasn’t able to change the start color or color over lifetime attributes.

To test that theory, make a quad, drive your material (the same one!) over to the quad at the same time you drive it to the ParticleSystemRenderer.

Can confirm that modifying the material on a normal quad works fine. In the end I decided to delete the particle system and reload my unity project and it seems to be working now. Really don’t know what went wrong there as I double checked that all the properties in the original particle system were correct.

I’ll probably end up reporting a bug to unity after some more testing

It probably isn’t a bug. Remember there’s a lot of stuff feeding into the renderer of a PS… such as color, just as one example. Some shaders (perhaps the default ones) are sensitive to things that others aren’t. Taking the color example, some shaders ignore alpha. Some don’t. If you configured one of your color cascade (base color, gradients, color over time, etc., which are generally all multiplied together) to return zero alpha, it might not affect one shader but it does affect another.