I'm using the Google Cardboard SDK. In older versions of Google Cardboard SDK, it included a file named AndroidManifest.xml
<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true"/>
So a solution could be to simple add that file back to my project.
However I don't like it because if I do it, the app is hidden in Google Play if the device doesn't have a gyroscope, and that's confusing for the users because they tend to search for it in Google Play.
So, how can I check if the device has a gyroscope from the code to show a message to the user like: this smartphone does have gyroscope. Please try with another smartphone.
You can check if there is a gyro sensor on the device with Input.isGyroAvailable
if (Input.isGyroAvailable)
{
//Gyro is available
}
That's now deprecated and should be used for really old version of Unity. For newer version of Unity, use SystemInfo.supportsGyroscope
.
if (SystemInfo.supportsGyroscope)
{
//Gyro is available
}