- Home /
Texture2D.readPixels error
Texture2D renderedMap = new Texture2D(GridControl.TileSize*GridControl.TileAcross, GridControl.TileSize*GridControl.TileHigh);
Rect gridSpace = new Rect(grid.position.x, grid.position.y, GridControl.TileSize * GridControl.TileAcross, GridControl.TileSize * GridControl.TileHigh);
renderedMap.ReadPixels(new Rect(gridSpace.x, gridSpace.y, gridSpace.width * 100, gridSpace.height * 100), 0, 0);
renderedMap.Apply();
//Save file
byte[] mapBytes = renderedMap.EncodeToPNG();
File.WriteAllBytes(Application.dataPath + "/Rendered Maps/rm" + gridSpace.width.ToString() + gridSpace.height.ToString() + ".png", mapBytes);
Error says: "Trying to read pixel out of bounds, reading (0, 0, 320, 320) from (235, 282)"
Any help is appreciated. This is all the applicable code there is.
Comment
Answer by Lazdude17 · Aug 03, 2015 at 11:06 PM
It just rendered this instead of the scene view!!!??? This is right under the heirarchy pane!
rm320192.png
(3.4 kB)