I have been having trouble trying to change the texture of a material using script. I attempted to make a very simple code that you click on a button and it changes the texture of a material. Below is the sample code. Does anybody have any suggestions or ways to do this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Button : MonoBehaviour {
public Texture Test;
public Material mat1;
void Update(){
RenderSettings.skybox = mat1;
}
public void PressButton(){
mat1.mainTexture = Test;
Debug.Log ("SetMainTex");
}
}