title: How to change canvas image via script
body: <p>I have a script, which change texture of the object (like a plane on the TV) fixed times per second:</p>
  
  <pre><code>public Texture[] frames;                // array of textures
  public float framesPerSecond = 2.0f;    // delay between frames
  
  void Update()
  {
      int index = (int)(Time.time * framesPerSecond) % frames.Length;
      GetComponent&lt;Renderer&gt;().material.mainTexture = frames[index];
  }
  </code></pre>
  
  <p>With this script I can change texture of plane, quad, etc. But I need to change it for canvas image. I can't change "Image" script. Should I access value "Source Image" of this script? Would it be correct?</p>
  
  <p>And is so, how can I access <code>Image</code> component? I can't write this:</p>
  
  <p><code>Image image = GetComponent&lt;Image&gt;();</code></p>
  
  <p><a href="https://i.stack.imgur.com/GaKgZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GaKgZ.jpg" alt="enter image description here"></a></p>