Load a sprite as a texture from.

This works

public Texture testTexture;

void OnGUI() {
  GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), testTexture);
}

I can drag and drop a texture, that works fine.

However I am trying to make it more dynamic.

So, I have a folder called resources, with a selection of PNG files (1.png, 2.png, 3.png…) I have set to sprites. The following does not work.

	 	    Texture img = Resources.Load("1.png") as Texture;
		    if (img) {

		    GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), productTexture);
		    
		    } 

		    else {

		    Debug.Log("Something bad happened, but I was prepared for that");
		    
		    }

Suggestions?

don’t use file ending to load from resources.

try Resources.Load(“1”)