public class TexturePixelCollision
{
bool[] _pixels;
int width;
int height;
public TexturePixelCollision(Texture2D texture)
{
var colors = new Color[texture.Width * texture.Height];
texture.GetData(colors); // store the colors of the texture into this array
_pixels = new bool[colors.Length];
for(int i = 0; i < colors.Length; i++)
{
if (colors[i].A > 0)
{
_pixels[i] = true;
}
}
width = texture.Width;
height = texture.Height;
}
// methods you can put for accessing pixels
public bool HasPixel(int x, int y)
{
return _pixels[y * width + x];
}
}
public class TexturePixelCollision
{
bool[] _pixels;
int width;
int height;
public TexturePixelCollision(Texture2D texture)
{
var colors = new Color[texture.Width * texture.Height];
texture.GetData(colors); // store the colors of the texture into this array
_pixels = new bool[colors.Length];
for(int i = 0; i < colors.Length; i++)
{
if (colors[i].A > 0)
{
_pixels[i] = true;
}
}
width = texture.Width;
height = texture.Height;
}
// methods you can put for accessing pixels
public bool HasPixel(int x, int y)
{
return _pixels[y * width + x];
}
}