schellingb / UnityCapture

Streams Unity rendered output to other Windows applications as virtual capture device
420 stars 65 forks source link

Is it possible to send game view in high resolutions but to let window size of app keep smaller . #13

Open meganeroppy opened 3 years ago

meganeroppy commented 3 years ago

I'm using UnityCapture to send game view to other app. The resolution sent from Unity app want to be high resolution but window size of Unity app itself need to be smaller. Is it possible?

schellingb commented 3 years ago

If it's an exported, standalone Unity app you probably need to go through a render-to-texture camera to customize the resolution. If it's running inside the Unity editor, you can set a custom resolution for the play view which will also apply to UnityCapture. First google result explains it: https://answers.unity.com/questions/1193163/change-gameview-ratio-resolution-using-a-custom-in.html

meganeroppy commented 3 years ago

Thanks for replying. I would like to solve this on standalone Unity app, so could you give me something like sample sending high-resolution picture (like 1920x1080) from unity app in smaller size window (like 800x450) with UnityCapture? I tried to achieve this with some ways, but it seems like that out picture with UnityCapture only available when game view is being displayed, and out picture resolution is always equal to game view.

schellingb commented 3 years ago

Can you have a look at the UnityCaptureMultiCam scene in the UnityCaptureSample project? I think you can easily modify it to be just one camera by changing

    public Camera CaptureCamera1, CaptureCamera2;
...
        CaptureCamera1.targetTexture = new RenderTexture(CaptureResolutionWidth, CaptureResolutionHeight, 24);
        CaptureCamera2.targetTexture = new RenderTexture(CaptureResolutionWidth, CaptureResolutionHeight, 24);
...
        Graphics.DrawTexture(new Rect(    0, h, whalf, -h), CaptureCamera1.targetTexture);
        Graphics.DrawTexture(new Rect(whalf, h, whalf, -h), CaptureCamera2.targetTexture);

to

    public Camera CaptureCamera;
...
        CaptureCamera.targetTexture = new RenderTexture(CaptureResolutionWidth, CaptureResolutionHeight, 24);
...
        Graphics.DrawTexture(new Rect(    0, h, w, -h), CaptureCamera.targetTexture);

Also notice the public int CaptureResolutionWidth = 1920, CaptureResolutionHeight = 1080; which defines the render-to-texture size (sets the window independent size rendered and used by UnityCapture).