0
\$\begingroup\$

I want to my game build in devices with 18.5:9 ratio like Samsung S8 forced to be displayed as 16:9 ratio. I already set Aspect ratio mode to Custom and set it to 1.86 in Player Settings. I also overrided Android Manifest like this:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools" android:installLocation="preferExternal">
    <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
    <application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" android:isGame="true" android:banner="@drawable/app_banner">
  <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:screenOrientation="sensorLandscape" android:launchMode="singleTask" android:maxAspectRatio="1.86" android:resizeableActivity="false" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
  </intent-filter>
  <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
  </activity>
  <meta-data android:name="unity.build-id" android:value="633a700a-7389-4a19-972c-ac1f177788f8" />
  <meta-data android:name="unity.splash-mode" android:value="0" />
  <meta-data android:name="unity.splash-enable" android:value="True" />
  <meta-data android:name="android.max_aspect" android:value="1.86" />

  </application>
  <uses-feature android:glEsVersion="0x00020000" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-feature android:name="android.hardware.touchscreen" 
android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" 
android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
  </manifest>

And as you see add attributes like android:maxAspectRatio & android:resizeableActivity to AndroidManifest manually.

But by installing the app on devices with that specific ratio, the game still running full screen and out of the bounds. I am using Unity 2018.1.4f1 (64bit).

\$\endgroup\$
5
  • \$\begingroup\$ Could you define what you mean by "out of bounds" ? Is the desired result to run the game with a black border on the left/right of the screen on devices with 18.5/9 aspect ratio? Also is the game 2D or 3D? \$\endgroup\$
    – TomTsagk
    Nov 20 '18 at 9:32
  • \$\begingroup\$ @TomTsagk out of bounds means the game height is shown bigger than the device height and part of the game scene is out of the screen. I want it to be forced to have a black border on the left/right of the screen on devices. The game is 2d and using an orthographic camera with "screen space - camera" canvas. \$\endgroup\$ Nov 20 '18 at 17:51
  • \$\begingroup\$ So the camera scales to its aspect ratio that you selected, but you only need to scale it down? Did you try the camera's settings if there is something like "scale to fit" ? \$\endgroup\$
    – TomTsagk
    Nov 20 '18 at 17:53
  • \$\begingroup\$ I found there is an option in this devices, there is 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. when the toggle is off the game is displaying correctly. \$\endgroup\$ Nov 20 '18 at 18:03
  • \$\begingroup\$ Then I guess problem solved? I'd imagine most people don't activate 16:9 aspect by themselves, so it should work properly for the average user? If that is the case, it would be nice if you made an answer explaining how you solved the problem and marked it as correct, for future users. \$\endgroup\$
    – TomTsagk
    Nov 21 '18 at 9:59
0
\$\begingroup\$

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).

As the above sentences said (from this topic), Android will override manifest and we cannot control whether the app is running Full Screen or not on devices by this ratio. So I found we should edit Canvas functionality to be Full Screen with black space each side in this ratio (this comes when the design of the game was based on 16:9).

In Canvas Scaler component from UI Canvas, my setting was like this :

Canvas Scaler component

That means UI must fill Width of device that runs on it, without considering Height. That will work on normal ratios, but for ratios like Samsung S8 or Pixel 2 XL, we must tune Match variable to make height of the game match by height of the device screen.

Of course, this is a temporary solution and we must change our design to it can be full screen even on this wide ratios.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.