Change Texture of Plane with script

Hi everyone, i need change texture of plane with script, i have a empty plane and i want add an image as texture, this will be dynamically … thanks

simply use:

 var myTexture : Texture;  

then in your script:

 renderer.material.mainTexture = myTexture;

this script would be attached to the plane itself… to access the plane from another object, you would need to create a var for that:

 var thePlane : GameObject;

then use in the code:

 thePlane.renderer.material.mainTexture = myTexture;

I … thnsk but this not work… so i tested with this code … not work…

    private Texture _texture;
    void Start () {
            _texture = Resources.Load("3-photo") as Texture;
    	    renderer.material.mainTexture = _texture;

i have an image them i want load into plane

Check this video - YouTube

Simple C# code :

public Texture yourTexture ;

// then in the update function

GetComponent ().material.mainTexture = yourTexture;

Also, in higher version of unity ‘renderer.material’ is obsolete have to use ‘GetComponent ().material’ instead.

visit !