Foldable Field of View Guide – Unity

Foldable devices have a cover screen and a main screen that have different aspect ratios. The outer screen has an aspect ratio of 23.1:9 and the inner screen has an aspect ratio of 19:3. This means that extra considerations are needed to achieve the best user experience on either screen. Outside of foldable comparability, we recommend that you consider how the Field of View (FoV) is scaled.

Default field of view solution in Unity

Unity uses a vertical FoV (Hor+) for its cameras. The horizontal FoV option appears to convert into vertical FoV when switching between the main screen and cover screen.

This can result in an issue when playing games in landscape mode on foldable devices. When switching screens, the FoV appears to change, resulting in the scene appearing larger or smaller and parts of the screen being hidden or revealed. For an example, see the images below:

<em>Figure 1: Cover Screen, Vertical FoV (Hor+)</em>
Figure 1: Cover Screen, Vertical FoV (Hor+)
<em>Figure 2: Main Screen, Vertical FoV (Hor+)</em>
Figure 2: Main Screen, Vertical FoV (Hor+)

The above example uses vertical FoV (Hor+). The cover screen is using the intended FoV when launching the app. When switching to the main screen, notice the "zoom" effect, where the cube is much bigger and the sides of the plane are cropped.

<em>Figure 3: Cover Screen, Horizontal FoV (Vert-)</em>
Figure 3: Cover Screen, Horizontal FoV (Vert-)
<em>Figure 4: Main Screen, Horizontal FoV (Vert-)</em>
Figure 4: Main Screen, Horizontal FoV (Vert-)

In games where you need to see wide FoV like FPS or racing games, this could potentially give players a disadvantage. The above example uses horizontal FoV (Vert-). Notice how both cubes and planes appear much closer in size, compared to the vertical FoV example. Whilst we lose a small amount of vertical space, this is much less than when using vertical FoV.

Implementation

In order to achieve the above effect, we recommend using horizontal FoV (Vert-) in Unity. This can be achieved via C# by using Camera.HorizontalToVerticalFieldOfView(Angle, AspectRatio). For example:

float angle = 45;
float aspectRatio = Screen.width / Screen.height;

float fov = Camera.HorizontalToVerticalFieldOfView(angle, aspectRatio);

_camera.fieldOfView = fov;

The FoV needs to be updated every time the device switches display to ensure a consistent horizontal FoV. Unity uses a vertical FoV so we need to recalculate what the correct vertical FoV should be to maintain our horizontal FoV.

To detect when the device switches displays, we recommend using the WindowManager API, which is part of the Android Jetpack library. A Java Callback Adapter can be set up to call a native function, where the FoV can then be updated.

As this process is too complicated for a short guide, below are links to documentation on how to set up a Java Callback Adapter for the WindowManager API. There is a Samsung blog post and Codelab which work together to explain how to implement the WindowManager API for use in Unity.

Resources

Summary

We recommend that developers test their games on foldables and decide which axis to scale the FoV so the changes are less noticeable between the cover screen and main screen.