title: Unity randomly change image
body: <p>I am using Unity. I want to change the image randomly, maybe by pressing a button or trigger an event.</p>
  
  <p>I can think of a solution like this:</p>
  
  <pre><code>    public Image randomImage;
      public Sprite s0;
      public Sprite s1;
      public Sprite s2;
      public Sprite s3;
      public Sprite[] images;
      void Start(){
          images = new Sprite[4];
          images [0] = s0;
          images [1] = s1;
          images [2] = s2;
          images [3] = s3;
       }
      void changeImage(){
          Random rnd = new Random();
          int num = rnd.Next(0, 4);
          randomImage &lt;Image&gt; ().sprite = images[num];
          }
  </code></pre>
  
  <p>Then I can drag the sprite that I want to change into <em>randomImage</em> , and drag four image into s0, s1, s2, s3. 
  However, the number of images I want to choose from is much larger than 4, maybe 20. I don't know whether there is a smarter way to do so instead of creating 20 variables and drag 20 images into it. 
  Thank you. </p>