Forum Discussion
Unity Surface Duo Sample is broken
DStephensJr I haven't looked at Unity in a while, but I can confirm that last version update we did was for 2019.4 because it's the LTS version. It seems like each version of Unity slightly changes how it integrates with gradle and native packages, so will have to investigate newer versions to see if there's anything we need to update.
The DisplayMask jar file is our core dual-screen library, so the issues are more likely to be the sample itself, or interactions with how Unity is detecting device orientation.
Note that LandscapeLeft versus LandscapeRight refers to the the orientation with respect to the phone's controls, it does not refer to the left/right screens of the Surface Duo.
While it's not likely to be the cause of any of these issues, could you share which Unity version you're building with and which OS version your Surface Duo is running?
Thanks for the reply.
Yes. Every minor dot release of Unity seems to bring more trouble.
I have been able to move a little forward with Unity 2021.1.
This is what I've done:
Project Settings -> Player -> Publish Settings:
Build
Custom Main Gradle Template = Checked. "mainTemplate.Gradle"
Custom Gradle Properties Template = Checked. "gradleTemplate.properties"
in mainTemplate.Gradle, added a section from the sample duo-screenhelper/Screenshots/mainTemplate.gradle.
=====
allprojects {
repositories {
mavenCentral()
google()
jcenter()
flatDir {
dirs 'libs'
}
maven {
url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
}
}
=====
and from code examination and a little digging,
=====
dependencies {
implementation "com.microsoft.device.dualscreen:screenmanager-displaymask:1.0.0-beta2"
**DEPS**}
=====
This forced a change in Project Settings -> Player -> Other Settings
- Identification -> Minimum API Level = Android 5.0 (API 21).
For GradleTemplate.properties I had to add a couple lines:
I also added into the code Input.DeviceOrientation. I wanted to compare it against the Screen.Orientation to see if they matched (not always) and if there was something I could do to force the correct answer.
Currently, I finally get "IsDeviceSurfaceDuo" to return true. I am altering my own project and it may be causing some issues, but I have also checked on a Razer Phone 2 and everything has worked as expected.
I hope that this can be helpful to anyone that may be experiencing similar issues. I also hope, that I haven't introduced more problems in the process. 😉
:-Dan (@DStephensJr)