#API to dynamically select graphics API based on something at game app launch

1 messages · Page 1 of 1 (latest)

vocal tundra
#

Is there any unity API for android to dynamically select graphics API like Vulkan and OPENGLES3 based on something like device name or android version at game app launch? If no, how to achieve this today without export entire project to android studio? And also will official implement it at 2023.2 cycle, 2024 or later so unity user no longer needs to write a lot of custom code just to achieve this requirement?

wispy kelp
#

Yeah sure it's a bit of a manual process plugging in your own device/version requirements, but you don't need to export to Android Studio

hard flame
wispy kelp
hard flame
vocal tundra
vocal tundra
last prism
# vocal tundra 🤔 Btw I think still need to write aar plugin at android studio and drag into un...

You don't need AAR plugin, simply do this:

  • Create OverrideExample.java and place it in Unity project, copy contents from documentation Neil posted
  • In Unity project, enable Custom Main Manifest template in PlayerSettings
  • Open Assets\Plugins\Android\AndroidManifest.xml and replace com.unity3d.player.UnityPlayerActivity -> com.company.product.OverrideExample, that way your activity will be launched instead
  • That's it
vocal tundra
static mantle
hard flame
grave island
#

that's how Auto Graphics API selection generally works. It first checks for support for the top API, if it's supported, uses it. If it's not, it will fallback to the next one. So what you'd do is drag DX12 to the top of the API selection list and DX11 right before it in Player Settings.

#

Of course if you want to customize it, you can select "Generate Visual Studio solution" option in the build window when building for Windows, and write code there to do your custom detection logic and pass according command line parameter to the UnityMain() function.

hard flame
grave island
#

right, that was a wrong choice of words from me. There are two things at play:

  1. Graphics API list. For every built game, Unity serializes that list and it works as I described: Unity tries APIs one by one from top to bottom until it finds one it can use (or displays a dialog message it cannot use any);
  2. Auto graphics API checkbox in player settings. Enabling it will choose whatever default list for each platform that we determined it should be. For windows that only consists of DirectX 11 today. So if you want to enable DX12 first and DX11 second, you need to uncheck that checkbox, add DX12 and drag it to the top.
hard flame
grave island