So I found this code on youtube but I want to swap materials instead of textures, even though It’s the same I already have a bunch of materials prepared.
public Texture textures;
public int currentTexture;
void Update ()
{
if (Input.GetKeyDown(KeyCode.C))
{
currentTexture++;
currentTexture %= textures.Length;
GetComponent<Renderer>().material.mainTexture = textures[currentTexture];
}
}
Note that changing “public Texture textures;” into “public Material textures;” doesn’t work