hi guys
i want to grab the screen and save that as a texture of some sort so that i can use it for my game’s pause background.
please give me an example, thanks
You could also read the screen directly into a texture with ReadPixels Unity - Scripting API: Texture2D.ReadPixels
ye, that was the first thing i tried(i tried GetTempory and Release), but didnt work, was why i wanna see a example out of renderTexture for this kind of stuff
great, didnt know texture2d could actually do that, thanks mate
still, i would really like to see how to use RenderTexture to make this to work, coz (just as expected, the cost of screen grab to texture2D is too much for mobile), when i pause my game(now, i screen grab as texture2D and use as bg img), a (at least) 0.5 sec freeze before my pause window show up, totally not feasible
can some one plz show me a example using renderTexture to make this to work(since its playing with the render buffer, i think it will surely faster than grabing all the pixels in the screen grab to texture technique)
thanks a lot
So, you’re using a disabled camera with targetTexture set to your texture and calling Render() if the game is paused, correct?
ye, my case involves disable one of the camera which is shooting the essential elements.
previously, when i pause i just turn on the 2nd cam which is set to depth only, so it can see through the one underneath, but performance wise, i want to set that 2nd cam to solid color clear flag. so no more see through, and since that, the 1st cam can also be turn off while the 2nd one is on.
now with no see through, its very ugly with just a plain bg color
Take a look at this for a couple of different ways to grab the screen including render to texture:
http://wiki.unity3d.com/index.php/ScreenCapture
thx for letting me know, man, i can see how they use render texture technique, but sadly, the example shows it still involves pixels reading, encoding, then writing, then its no different than using texture2D.readPixel technique, i reckon it will take exactly the same cost too.
i thought we could use those renderbuffers frames which has been rendered and kept in G-ram for a couple of frames, which contains byte[ ], color[ ] or depth[ ](from the Unity doc, its said these are the data that to be played with those post render Fx), so i thought maybe i could just grab that straight out of the pool, and have zero cost in doing so:face_with_spiral_eyes:
What are you actually trying to do? To save the image you have to get it out of the graphics ram and across to long term storage.