Currently, i’m using this method to get the pixels’ color of my Texture2D
Color[] pixelColours = new Color[MyTexture.Width*MyTexture.Height];
MyTexture.GetData<Color>(pixelColours);
- As you can see, I store every pixels’ color in a tab.
- The texture2D is pretty huge : 1000 pixels x 1000 pixels.
- But I only need to get 1 pixel’s color, it means i store 999.999 useless others pixels.
- The pixel’s position on the Texture2D is moving, so this code is in the Update() method.
Are there others ways to get this only 1 pixel very fast with low memory cost ?
The GetData method is overloaded and allows you to specify a starting pixel and how many elements to get: http://msdn.microsoft.com/en-us/library/bb197093.aspx.