How can I add image to plane by script?

I want to change image on plane by click, one click for one change.
Please tell me how can I write this script?
(probably in C#)

thank you :slight_smile:

Hi, There are two ways you can go about doing this

1.By channging the materials assigned to it(More control over nomrmal maps and specular)

public GameObject ThePlane;

public Material[] MaterialArray;

int index =0;
void OnGUI()
{
 if (GUI.Button(Rect(10,70,50,30),"Click"))
 {
  index = (index < MaterialArray.Lenght) ? index++ : 0;
  ThePlane.renderer.sharedMaterial = MaterialArray[index];
 }
}

Alternate Method

public GameObject ThePlane;
public Texture2D[] TextureArray;

int index =0;
void OnGUI()
{
if (GUI.Button(Rect(10,70,50,30),"Click"))
{
 index = (index < TextureArray.Lenght) ? index++ : 0;
 ThePlane.renderer.material.SetTexture("_MainTex",TextureArray[index]);
}
}