Applying a texture to a plane

Hi, I’m trying to apply a texture to a plane. I imported the psd file as an asset but I don’t know what to do with it. I’ve searched the tutorials but I can’t figure out how to apply a texture to a 2d plane. It would be nice if I could know how to do it at runtime AND how I can apply it before running the program.

Hi, in the editor mode is it very easy, you only need to create the plane, and put the texture on it with drag and drop from the project folder into the scene view plane. Unity will automatically creates a Material folder for you with the material on the object.
The other way is to create the material by yourselve (Assets-Create-Material) and put the texture on it in the inspector, drag and drop the material in the scene view like before or assign it in the hirarchy to the plane.
An advice, dont work with photoshop files, they are very large. Convert the psd files to an other format like png or jpeg before importing it to unity.

If you want to change texture while runtime, the easiest way is to put a script on the plane with following code (JaveScript):

public var myTexture : Texture;
renderer.material.SetTexture("_MyTexture", myTexture);

If you want to change the material only under a certain conditions and not at startup, for example key input, you have to put the sceond line in the update function and ask for it in an if condition.

Don’t know anything about psd, but i apply texture on maya’s plane the following way:

public GameObject go; //your plane
void ApplyTexture(Texture texture) {
  renderer.material.mainTexture = texture;
}

How to apply texture before running: put your prefab into scene. You’ll see it’s mesh renderer in inspector view. Then create new material with your texture and put your new created material to that mesh renderer.

Would now be:

public GameObject go; //your plane 
void ApplyTexture(Texture2D texture) { 
  go.GetComponent().material.mainTexture = texture; 
}

(based on @Rustam-Ganeyev answer)