Getting inverted Y axis from Texture2D.GetPixel()

This questions complete source code/project is located in this thread:

http://forum.unity3d.com/threads/198919-Destructible-Pixel-Terrain-Open-Source

and my question is this:

I try to do a method to get whether or not the alpha of a certain pixel is 0 or 1. when I do this thought I check for pixels that are from top left of the level. This ends up being around the place it spawns in the player (100, 100 if top left is 0, 0) and when I run those x y through texture2d.getpixel(x, y) it ends up giving me the pixels in the bottom left corner of the texture, however I need the pixels from top left…

It must be something simple like a line of some math to get it working, how could I get my Y to be on my player (which gives its location apparently from top left rather than bottom right… so the very top left would be 0, 0…) and remember that x works its directly below the player (who is near top left corner at spawn, see that thread)

anybody had this problem? I feel like its stupid simple… lol

Here is an image to describe my problem better:

alt text

Yea, I think texture2d.GetPixel’s (0,0) is bottom left of the texture. To get the pixel from top left you could use:

texture2d.GetPixel(x, texture2d.height - y);

Maybe?

This should be in the coding reference or at least more well known. It killed me for hours spread out over a couple days, while I was trying to retrieve coordinates for full red pixels.

It was pretty ridiculous for something that can be so simply relayed.