Hello, I have a list of GameObjects and their materials that I’m trying to apply changes to via C# scripts.
I run this function every Update()
void Warp() {
foreach (GameObject obj in Objects)
{
obj.GetComponent<MeshRenderer>().sharedMaterial.SetVector("Offset", new Vector4(-10, 50, 30, 40));
Debug.Log(obj.GetComponent<MeshRenderer>().sharedMaterial.name);
}
}
According to my debug logs, it’s affecting all of the GameObjects in the list properly, yet when I run it there are NO noticeable changes to the Offset vector in the game AND in the inspector.
This topic seems to explain the same issue, and a comment there suggests that it has to do with the inspector dictating the values in the shader instead of the script. However, when I close the inspector, nothing happens still.
Any ideas on why this happens?