- Home /
SetPixels "Texture rectangle is out of bounds"
I want to cover an area in the 2D Texture with a specific color, I don't need mip or whatever effect.
My first question is if this would be possible without using huge array that contains the same color?
The other question is why when i run this it will say Texture rectangle is out of bounds?
Color[] colorsArr = new Color[enginePowerheight * enginePowerWidth];
for(int i=0;i<colorsArr.Length;i++) { colorsArr[i] = Color.black; }
display.SetPixels(sizeX - 21,sizeY-6,enginePowerWidth,enginePowerheight, colorsArr);
Thanks.
Answer by PaulUsul · Jan 15, 2011 at 10:25 PM
Hi,
That is probably because the area you are trying to fill is smaller than the array you have made, I can't know without seeing more code.
But I imagine it's a situation like this:
Texture2D display = new Texture2D(1,1);
Color[] colorsArr = new Color[2 * 2];
for(int i=0;i<colorsArr.Length;i++) { colorsArr[i] = Color.black; }
display.SetPixels(0,0,2,2, colorsArr);
If not try debugging out all the size of the variables and posting them :)
Answer by 孤孤瓜 · Mar 08, 2013 at 06:20 AM
Texture2D.SetPixels(int x,int y,int widthX,int widthY,Color[] colors,int mip); 只要保证(X+widthX)<= texture.width && (Y + widthY) <= texture.height 就不会有 “Texture rectangle is out of bounds”这个错误