2D Toolkit Forum
2D Toolkit => Support => Topic started by: gonzalez.martin90 on January 16, 2015, 04:27:29 pm
-
Hey! I'm trying to make a screenshot of a certain camera (tk2d Cam clipped) and something strage is giving me as texture.
Seems that what the camera sees its ok but its doing like something strange around.
Any idea? I'm using RenderTexture
Thanks!
-
If its clipped then the rt won't be filled, i.e. you'll have whatever was left over. You'll need a second camera drawing into this RT to fill in the parts of the texture outside.
-
Thanks for answering.
Yes i understood it, but what i want is to take a screenshot of that clipped camera and have a "full screen" screenshot.
I did a new method that works like this:
public Texture2D TakeScreenShot(Camera camera, Bounds bound)
{
#if UNITY_ANDROID
Texture2D snapShot = new Texture2D((int)camera.pixelWidth , (int)camera.pixelHeight, TextureFormat.RGB24, false );
snapShot.ReadPixels( new Rect( camera.pixelRect.xMin, camera.pixelRect.xMin, (int)camera.pixelWidth, (int)camera.pixelHeight), 0, 0, false );
snapShot.Apply();
return snapShot;
#endif
return new Texture2D(100,100);
}
The code seems to be ok, but the height of the screenshot is more than expected
(https://dl.dropboxusercontent.com/u/15741059/Screen%20Shot%202015-01-16%20at%201.53.55%20PM.png)
-
it seems to be offset because if i modify this
snapShot.ReadPixels( new Rect( camera.pixelRect.xMin, camera.pixelRect.xMin-40, (int)camera.pixelWidth, (int)camera.pixelHeight), 0, 0, false );
that 40 modify the Y offset but depends on the resolution. I cant know which calculation i have to do to have the exactly point and size
-
I don't understand why you're not reading all the pixels in the render texture? If xMin != 0 you won't be reading into all pixels in the texture2D, and be left with random pixels in there.