title: Unity: GetPixels() always results in the colour black across whole image
body: <p>I have an image (attached) which I'm using as a test. I'm trying to get and store all the colours of each pixel in an array.</p>
  
  <p>I use the below code to do this;</p>
  
  <pre><code>    Texture2D tex = mapImage.mainTexture as Texture2D;
  
      int w = tex.width;
      int h = tex.height;
      Vector4[,] vals = new Vector4[w, h];
  
      Color[] cols = tex.GetPixels();
      for (int y = 0; y &lt; h; y++)
      {
          for (int x = 0; x &lt; w; x++)
          {
              if(cols[y+x] != Color.black)
              {
                  Debug.Break();
              }
  
              vals[x, y] = cols[(y + x)];
          }
      }
  </code></pre>
  
  <p>Where mapImage is a public Material variable which I drag in into the scene on the prefab. As you can see, I've added a debug test there to pause the editor if a non-black colour is reached. This NEVER gets hit ever.</p>
  
  <p>Interestingly, I've got another script which runs and tells me the colour values (GetPixel()) at the click position using the same image. It works fine (different methods, but both ultimately use the same material)</p>
  
  <p>I'm at a loss as to why GetPixels() is always coming out black?</p>
  
  <p>I've also been considering just loading the image data into a byte array, then parsing the values into a Vector4, but hoping this will work eventually.</p>
  
  <p><a href="https://i.stack.imgur.com/BNg1m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BNg1m.png" alt="enter image description here"></a></p>