SetPixels ??? I'm confused

Hi,

		Texture2D texture = new Texture2D(size, size, TextureFormat.RGBA32, false);
		
		renderer.material.mainTexture = texture;

		Color32[] color = new Color32[size2];
		
		
        int y = 0;
        while (y < texture.height) {
            int x = 0;
            while (x < texture.width) {
				color [x+y] = new Color32(128,0,0,255);

                ++x;
            }
            ++y;
      	 }
	texture.SetPixels32(color,0);
        texture.Apply();

}

I can’t get this to work. All I get is a red line painted down one edge of the texture. Can someone help me out?

Thanks

Using x+y won’t work; as the docs say, “The colors array is a flattened 2D array, where pixels are laid out left to right, bottom to top (i.e. row after row).” So you need to multiply y by the width.

–Eric

Thanks! :slight_smile:

I’m such an idiot.