How to change texture of material using script?

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");
	}



}

You should use texture2d. And take the skybox out of update and put it in start or rather create a function to switch between an array or list of skybox materials.