Material.SetTexture doesn't work if not "_MainTex"
So, I have a script that sets and gets the texture from the current material to work on it. The Texture2D is always loaded and non-null.
I also am using a ShaderGraph shader and have a property for a 2D texture exposed on there.
When the property name is "_MainTex" everything works, but when changed to "_BaseMap" to work with URP/Lit, neither that shader nor my own (after changing the property reference) work anymore!
I've double-checked everything and have only found that "_MainTex" works but if I change to any other name, nothing works anymore.
As an extra note, I have also tried using the Material.mainTexture property, but that also doesn't work for the URP shaders.
I'm currently working in Unity 2020.3.22f1 with URP version 10.7.0.
Am I missing something?
public void SetMainTexture(Texture2D newTexture)
{
this.GetComponent<Renderer>().material.SetTexture("_BaseMap", newTexture);
}
public Texture2D GetMainTexture()
{
return (Texture2D)this.GetComponent<Renderer>().material.GetTexture("_BaseMap");
}