- Home /
Application.CaptureScreenshot on a Texture2D?
Is it possible to take the texture from Application.CaptureScreenshot and put it on a Texture2D?
Answer by flamy · Jun 02, 2013 at 12:06 PM
You need to use RenderTexture (pro only) to do that. create a script and apply it to camera and copy the code to a IEnemurator function in that script.
RenderTexture.active = camera.targetTexture;
Texture2D texFront = new Texture2D(camera.targetTexture.width,camera.targetTexture.height,TextureFormat.RGB24,false );
texFront.ReadPixels(new Rect(0,0,512,512), 0, 0);
texFront.Apply();
yield return null;
Manager._instance.side = -1;
_shirtHandler.LoadPattern();
yield return new WaitForEndOfFrame();
camera.Render();
RenderTexture.active = camera.targetTexture;
Texture2D texBack = new Texture2D(camera.targetTexture.width,camera.targetTexture.height,TextureFormat.RGB24,false );
texBack.ReadPixels(new Rect(0,0,512,512), 0, 0);
texBack.Apply();
you can create a rendertexture at run time or create one and apply it earlier to the camera.... Note that you have to replace the value 512 in my code with what ever height and width you screenshot has.
you don't need RenderTexture to use ReadPixels to screenshot... I guess also what I meant was if it's possible to have capturescreenshot generate the png and then something in-game can us the corresponding Texture2D
hmm then after saving screenshot, why dont you use www class to load the file from local...
screenshot is saved in Application.persistentDataPath.
Your answer
Follow this Question
Related Questions
Texture.Apply() Crashes at Resolutions under 1920x1080 1 Answer
Screenshot to variable 1 Answer
Using Screenshot as Texture 4 Answers
Update Texture type to GUI during runtime 0 Answers
Converting a RenderTexture to a Texture2D for use in a shader 2 Answers