public static Texture2D CreateCheckerTexture(int numCols, int numRows, int cellPixelWidth, Color col1, Color col2)
{
int height = numRows * cellPixelWidth;
int width = numCols * cellPixelWidth;
Texture2D textured = new Texture2D(width, height, TextureFormat.RGBA32, false) {
hideFlags = HideFlags.HideAndDontSave
};
Color[] colors = new Color[width * height];
for (int i = 0; i < numRows; i++)
{
for (int j = 0; j < numCols; j++)
{
for (int k = 0; k < cellPixelWidth; k++)
{
for (int m = 0; m < cellPixelWidth; m++)
{
colors[((((i * cellPixelWidth) + k) * width) + (j * cellPixelWidth)) + m] = (((i + j) % 2) != 0) ? col2 : col1;
}
}
}
}
textured.SetPixels(colors);
textured.Apply();
return textured;
}