There are new "foldable" mobile devices such as Samsung foldable phones.
Is there any way we can write a C# script in Unity to detect if the device is a foldable phone ?
I try, but can't find any online tutorial on how to do this yet.
Searching for "samsung foldable phone api" brings up the Android developer documentation on foldables which links to the information on making your app fold aware:
To make your app fold aware, use the Jetpack WindowManager library, which provides an API surface for foldable device window features
All of the code examples in the above mentioned Android developer documentation are in Java or Kotlin. However, searching for "Jetpack WindowManager library c#" brings up Microsoft's documentation for the Jetpack Window Manager for Unity. The Microsoft docs include Unity game samples for Surface Duo and an accompanying explainer blog post:
To access the new APIs from Unity, copy the C# code from the file SurfaceDuoScreenHelper.cs from GitHub into your game. This will provide the following functionality:
DeviceHelper.IsDualScreenDevice – Call this method before accessing other dual-screen APIs.
IsDualScreenDevice() returns a bool indicating whether your app is running on a dual-screen device.