- Home /
Question by
Artworkz · Jun 21, 2015 at 11:31 AM ·
screenshotgetpixel
Get Pixels from rectangle center of a texture
function TakeScreenShot (name : String) {
yield WaitForEndOfFrame(); // this also captures gui, remove if you don't wanna capture gui
var shot = new Texture2D(Screen.width,Screen.height,TextureFormat.RGB24,false);
shot.ReadPixels(Rect(0,0,Screen.width,Screen.height), 0, 0, false);
if(shot.width > 1024 || shot.height > 512)
TextureScale.Bilinear(shot,2, (4.0/parseFloat(Screen.width))*Screen.height);
shot.Apply();
var TextureColor = shot.GetPixel ( 1,1 );
Application.CaptureScreenshot("/Assets/Screenshot.png",1);
print(TextureColor);
Hi i need to get the color of the middle of a texture var TextureColor = shot.GetPixel ( 1,1 ); But i get allways wrong color-value.
Comment
Answer by Eennou · Jan 06 at 12:06 PM
A bit late answer... The fact is that getPixels() counts pixels from the lower-left corner. Use something like this to take the center pixel:
var TextureColor = shot.GetPixel(shot.width/2, shot.height/2);
Your answer
