I’m currently calling material.setVector("_MyVectorName") on a Shader Graph backed material in one of my scripts. It works great, but the problem is that it changes the parameter in the actual material file too, which means the changes show up in my version control system every time I play the game.
Is there a way to set a parameter like this at runtime without actually changing a file?
I figured it out!
A .material file is basically a material prefab, so when you change a parameter on it, you’re changing the prefab. However, once you drag a material into a renderer component, you’ve now created an instance of that material, and you can make changes to that instance without affecting the original material.
So, if you’re going to call material.SetVector (or .SetWhatever), make sure you call it on a material that you pulled out of a renderer (like by doing someRenderer.material.SetVector) rather than directly on a material file.