What are the best practices to draw images from script?

I have a simple 2D game and in a click of a button I want to draw a random image.
Is there a simple way to draw sprites from script?
I don’t want to use OnGUI (with DrawTexture) and I’d rather not create prefabs from all of my images.

This question is too general as it stands. The ‘best’ way to display the images will depend on a number of factors including how you want to handle changing resolutions and if the images have the same aspect ratio. Primary ways to display an image are:

  • OnGUI.DrawTexture()
  • GUITexture()
  • Using a Quad with a material and a texture

For your set of images, put them in an array and initialize the array either through drag and drop or Resources.LoadAll(). Select the image and asign using Random.Range().