I searched and found one other thread that also stalled with this unanswered - see here : Changing HDRP Material's Texture At Runtime Not Working? - Questions & Answers - Unity Discussions
I am using Unity 2020.1.4f1
I am trying to change the base map of an HDRP material (which is used on many different objects - buildings).
I have coded as follows (excerpt):
[SerializeField] private Material Building_Cladding;
public Texture Grey;
public Texture Cladding_Waves;
// in void update
// Geology
if (Input.GetKeyUp("z"))
{
Debug.Log("Switching texture for albedo on :" + Building_Cladding.name);
// Building_Cladding.SetTexture("_MainTex", Waves);
Building_Cladding.mainTexture = Cladding_Waves;
Building_Cladding.color = Color.green;
Debug.Log("Switched color to :" + Building_Cladding.color);
}
I added the material and the textures to my script in the editor GUI.
In my debug it states that my texture has changed. The output states :
“Switching texture for albedo on :OFA_Side_Cladding”
“Switched color to :RGBA(0.000, 1.000, 0.000, 1.000)”)
but nothing changes in the actual scene at run time.
What is the correct method to change the base map texture of a Material (which is used by many objects)? Is this a bug ?
Thanks for any help…
D.