changing material attributes at runtime

For some reason....Unity doesn't let me change Material attributes at run-time, with scripts... On selecting the offending Material in the Inspector it will suddenly update, but if left to it's own devices...nada.

Apparently if you make a copy of the material and assign it to a disabled/hidden gameobject in the scene, then alter the material to be how you want it, on running the game your original material should function as desired. - this however didn't work for me :(

But....it seems for what I was doing (altering the emission colour), simply setting the material's emission above 0 allowed the script to function properly.

The internet suggested "shared materials" and "shader variants"...but I haven't had much luck with those either...

Comments

Popular posts from this blog

Unity's "new" input system and Keijiro's Minis midi stuff

compute shader with skinned mesh flocking instances

setting VFX graph properties using C#