x


Trying to read pixel out of bounds - screenshot of just half the screen

I am trying to take a screenshot of just half the screen. Taking the full screenshot, and sending it to webform works, just like in this example. Each time I try it with just half the screen, I get the fatal error,

"Trying to read pixel out of bounds

UnityEngine.Texture2D:ReadPixels(Rect,Int32,Int32)"

tex.ReadPixels( Rect(Mathf.Round(width*0.5), 0, width, height), 0, 0 );

width and height are assigned as floats:

var width = Screen.width;
var height = Screen.height;
more ▼

asked Dec 26 '10 at 03:10 PM

ina gravatar image

ina
3.3k 492 551 602

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You're trying to make the rectangle "Screen.width" wide, but you start reading halfway across the screen. You need to make it as wide as only half the screen.

more ▼

answered Dec 26 '10 at 04:19 PM

Jessy gravatar image

Jessy
15.6k 72 95 196

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x486
x355
x104
x37
x7

asked: Dec 26 '10 at 03:10 PM

Seen: 2077 times

Last Updated: Dec 26 '10 at 03:10 PM