You can extend the custom Unity activity to pass command-line arguments when you launch the Android Player. For information on the available command-line arguments, refer to Command-line arguments.
To specify startup command-line arguments in custom activity:
Create a custom activity and set it as the application entry point.
In the custom activity, override the String UnityPlayerActivity.updateUnityCommandLineArguments(String cmdLine)
method.
In the method, concatenate the cmdLine
argument with your own startup arguments, then return the result.
Important: The cmdLine
argument can be an empty string or null. Make sure your code handles these possible values.
The following example shows how to specify startup arguments to select the graphics API based on the current device:
package com.company.product;
import com.unity3d.player.UnityPlayerActivity;
import android.os.Bundle;
import android.os.Build;
public class OverrideExample extends UnityPlayerActivity {
private boolean preferVulkan() {
// Use Vulkan on Google Pixel devices
if (Build.MANUFACTURER.equals("Google") && Build.MODEL.startsWith("Pixel"))
return true;
else
return false;
}
private String appendCommandLineArgument(String cmdLine, String arg) {
if (arg == null || arg.isEmpty())
return cmdLine;
else if (cmdLine == null || cmdLine.isEmpty())
return arg;
else
return cmdLine + " " + arg;
}
@Override protected String updateUnityCommandLineArguments(String cmdLine)
{
if (preferVulkan())
return appendCommandLineArgument(cmdLine, "-force-vulkan");
else
return cmdLine; // let Unity pick the Graphics API based on PlayerSettings
}
@Override protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
}
Apart from the custom activity, you can specify command-line arguments in the following ways:
adb shell am start -n "<package_name>/<activity_name>" -e unity \"<command_line_arguments>\"
Use the following code example to pass -systemallocator
command-line argument to your application.
adb shell am start -n "com.Company.MyGame/com.unity3d.player.UnityPlayerActivity" -e unity \"-systemallocator\"
Use the following code example to pass -platform-android-jobworker-affinity
command-line argument with value little
to run the Unity job worker threads on little cores. For more information, refer to Android thread configuration.
adb shell am start -a android.intent.action.MAIN -n "com.Company.MyGame/com.unity3d.player.UnityPlayerActivity" -e unity \"-platform-android-jobworker-affinity little\"
螃蟹和什么食物相克 | 不以为然的意思是什么 | 落幕是什么意思 | 解肌是什么意思 | 鸡鸡长什么样 |
相夫教子是什么意思 | 遇上方知有什么意思 | 女生纹身什么图案好看 | 观音菩萨属什么生肖 | 一什么春雷 |
日本的国宝是什么 | 驿站是什么意思 | 月经什么颜色的血是正常的 | 手表五行属什么 | 免疫力差吃什么 |
是什么词性 | 取环后月经量少是什么原因 | 白天为什么能看到月亮 | 前列腺吃什么食物调理 | 幽冥是什么意思 |
牛油果是什么季节的水果hcv8jop8ns8r.cn | 天生丽质难自弃是什么意思hcv9jop5ns1r.cn | 属虎的和什么属相最配hcv7jop6ns2r.cn | 咲念什么hcv8jop2ns8r.cn | 喝红牛有什么好处和坏处hcv8jop1ns7r.cn |
嗜睡是什么原因hcv9jop2ns2r.cn | 阴虚体质是什么症状hcv9jop3ns4r.cn | 什么来迟hcv9jop5ns0r.cn | 氢化聚异丁烯是什么hcv7jop7ns4r.cn | 老人住院送什么东西好hcv9jop2ns5r.cn |
无花果什么品种最好吃aiwuzhiyu.com | 当逃兵会有什么后果hcv7jop7ns2r.cn | hpmc是什么hcv9jop1ns6r.cn | 龟头炎用什么药好hcv7jop5ns4r.cn | 后援团是什么意思hcv8jop3ns4r.cn |
bdsm什么意思gangsutong.com | 小孩补铁吃什么shenchushe.com | 18号来月经什么时候是排卵期hcv8jop7ns8r.cn | 破伤风什么情况需要打hcv9jop2ns9r.cn | 什么人容易得白血病hcv9jop5ns4r.cn |