I used to change the BaseMap texture using the standard 3D project in unity as follows:
[SerializeField] private Texture texture;
void Start()
{
this.GetComponent<Renderer>().material.mainTexture = texture;
}
However, the same code doesn't seem to work using the Universal RP Template. When I checked the shader properties, it shows that the BaseMap property is obsolete as shown in the picture below:

But when I drag and drop the texture at run time to the BaseMap, it works. I guess that means that it should work. (Below Pic):

My MAIN question now is, how do I change the BaseMap texture from script in Universal RP Template?
and is there other properties I should call and change their texture other than the BaseMap since it's written on the shader that the BaseMap is "ObsoletProperties"?
Update, this should do the trick:
[SerializeField] private Texture texture;
void Start()
{
GetComponent<Renderer>().material.SetTexture("_BaseMap", texture);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With