I have a car and i would like to change it's texture when I press a GUI button

using UnityEngine;
using System.Collections;

public class texturechange : MonoBehaviour {

	public Texture[] myTextures = new Texture[5];
	int maxTextures;
	int arrayPos = 0;
 	
void Start ()
    {
        maxTextures = myTextures.Length-1;
    }
 
 
//void Update ()
//    {
//        if (Input.GetKeyDown(KeyCode.T))
//        {
//            renderer.material.mainTexture = myTextures[arrayPos];
// 
//            if(arrayPos == maxTextures)
//            {
//                arrayPos = 0;
//            }
//            else
//            {
//                arrayPos++;
//            }
// 
//        }  
//    }

void OnGUI ()
    {
        if (GUI.Button(new Rect(15,15,100,50),"textures"))
        {
			if(Input.GetMouseButton(0))
			{
            renderer.material.mainTexture = myTextures[arrayPos];
 
            if(arrayPos == maxTextures)
            {
                arrayPos = 0;
            }
            else
            {
                arrayPos++;
            }}
 
        }  
    }
}

Methods Input.GetMouseDown() and etc aren’t use in OnGUI(). Change code:

 void OnGUI () {
  if (GUI.Button(new Rect(15,15,100,50),"textures")) {
   renderer.material.mainTexture = myTextures[arrayPos];
   if (arrayPos == maxTextures) {
    arrayPos = 0;
   } else {
    arrayPos++;
   }
  }  
 }

I hope that it will help you.

i was able to achieve the functionality but by an unorthodox way.
I MADE AN ARRAY OF ALL THE SURFACES I NEEDED TO CHANGE. THE APPLIED THE TEXTURE TO THE WHOLE ARRAY AND IT WORKED PERFECTLY.
the only pros it has is that you can always specify new surfaces to which you want to apply texture.
and the cons :-
1)you have to select each surface manually, wasting a lot of time.
2)it is not very memory efficient.