cancel
Showing results for 
Search instead for 
Did you mean: 

In game photo booth?

Hexapuss_Steve
Heroic Explorer
Is it possible via Unity script to trigger the Oculus save screenshot function so the player can save pictures with an in game button? 
Ideally the saved image will be from a separate pre-framed camera.
1 ACCEPTED SOLUTION

Accepted Solutions

MikeF
Trustee
I dont think oculus has an API for this but you can just do it through unity
it would look something like this
RenderTexture rt = new RenderTexture(RES_WIDTH, RES_HEIGHT, 24);
RenderTextureCamera.targetTexture = rt;
Texture2D screenShot = new Texture2D(RES_WIDTH, RES_HEIGHT, TextureFormat.RGB24, false);
RenderTextureCamera.Render();
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, RES_WIDTH, RES_HEIGHT), 0, 0);
screenShot.Apply();
Then to save it
byte[] bytes = screenShot.EncodeToJPG();
System.IO.File.WriteAllBytes(filename, bytes));

View solution in original post

5 REPLIES 5

MikeF
Trustee
I dont think oculus has an API for this but you can just do it through unity
it would look something like this
RenderTexture rt = new RenderTexture(RES_WIDTH, RES_HEIGHT, 24);
RenderTextureCamera.targetTexture = rt;
Texture2D screenShot = new Texture2D(RES_WIDTH, RES_HEIGHT, TextureFormat.RGB24, false);
RenderTextureCamera.Render();
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, RES_WIDTH, RES_HEIGHT), 0, 0);
screenShot.Apply();
Then to save it
byte[] bytes = screenShot.EncodeToJPG();
System.IO.File.WriteAllBytes(filename, bytes));

Hexapuss_Steve
Heroic Explorer
Thanks @MikeF , I will give your solution a go!
DM me if you'd like a free game code for my game Metal Multiball.
Cheers! 

Anonymous
Not applicable
I have scripts doing this in my app - Unity, let me know if you need them.

Hexapuss_Steve
Heroic Explorer
Thanks @lukeskywatcher , I hope you're doing great.
Do you use the same technique MikeF recommends?

Anonymous
Not applicable
Hey Steve, doing grand thanks, hope same for you. Using similar method as MikeF, I switch briefly to a 3rd person camera to take the shot. You can tweak to take pictures at current user resolution, or at fixed game resolution etc. Best luck!