- Home /
 
               Question by 
               ina · Dec 26, 2010 at 03:10 PM · 
                texture2dscreenscreenshotreadpixelshalf  
              
 
              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;
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Jessy · Dec 26, 2010 at 04:19 PM
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.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                