Our apps are strictly 2d (using 2d toolkit), and are designed to do a combination of scaling and positioning to handle the range of mobile aspect ratios from 4:3 to 16:9. They could even go a little longer, but Samsung S8 is a bewildering 18.5:9(2960x1440).
Unfortunately, we never anticipated a phone designed to be that long and thin, and our camera overrides/scaling aren’t cutting it with the background images. Meanwhile, my camera bottom left/top right anchors have stuff floating over the empty space the background doesn’t reach.
What I need to do is just totally ignore around 400 pixels (preferably leaving it black on either side, or one side, whatever), to bring it down to a reasonable 16:9 (2,560x1,440).
Is there some easy way to do this without manually recoding all of my anchors? Cross posted on 2dtoolkit forum because wasn’t sure if there were any 2dtk tricks that might help.
If you are using Unity 2017.2 or later, go to "Player Settings → Resolution and Presentation, chose “Custom” as an “Aspect Ratio Mode” and enter 1.86. For older Unity versions you will have to edit Android Manifest. Here’s official info on what you’ll have to add نظرة عامة على توافق الشاشة | Android Developers (note that you’ll want 1.86 or similar values instead of recommended 2.1 or higher).
Another thing to note is that Samsung phones tend to remember if your app was opened in “full wide screen” and even modifying the manifest may still open them in “full wide screen” (there should be a toggle in settings for each installed app which allows choosing whether the app should use a full screen or just a 16:9 aspect part of it). If you run into this issue, uninstall your app from the device and then install it again instead of doing an app update.
So far, doesn’t seem to be working when I test though.
I set the PlayerSettings to “Legacy”/186
I copied the androidmanifest into my plugins/android directory and modified it, adding to activity:
android:maxAspectRatio=“1.86” android:resizeableActivity=“false”
AND
When I run the app (even on a completely clean install, or a freshly made emulator) it still runs full screen.
Even more bizarre, when I open the APK in Android studio and view the included AndroidManifest.xml I see this:
android:maxAspectRatio=“1072567424.000000”
Why would it change from 1.86 to that huge number?!
Sorry, no, can’t really think of situation where that would work with a 2d game, pretty much always would look terrible since the art would be all distorted.
The max aspect ratio @JuliusM posted is the answer, if only I could get it to work
As in my previous response I suggest to use “Custom” (with 1.86 value) instead of the “Legacy”. Legacy in this case means “works the same as in old Unity versions” and depending on a few things there might be nothing added to the manifest. On the other hand choosing “Custom” will always specify max aspect ratio in the manifest, but please note that according to android docs (which I’ve linked previously) different manifest attributes / elements are used depending on Android version. So when you’ll set “Custom with 1.86” try building your app with target sdk level lower than 26 and then with 26 or higher (two variants). See if the result will differ when you’ll run those versions on the device.
This should be a valid alternative to using Unity editor Player settings and should work the same.
Did you run your app on the physical device or only on the emulators? It could be that emulators always scale your app and ignore max aspect ratio values. If possible, I’d strongly suggest to test on the actual physical device.
I’ve just tried this and can confirm this is shown in the apkanalyzer tool. However I think this is likely an issue of the apkanalyzer and the number is formatted incorrectly. I’d suggest to do the following: Build the apk with Unity editor and don’t close the editor. Go to your project location and inspect the Temp/StagingArea/AndroidManifest.xml file. This is the final version of Android manifest after all manifest merging is done, before it is packed into the apk file.