커스텀 Unity 활동을 확장하기 위한 사용 사례는 Android 플레이어를 실행할 때 커맨드 라인 인자를 전달하는 것입니다. 사용 가능한 커맨드 라인 인자에 대한 내용은 커맨드 라인 인자를 참조하십시오.
커스텀 활동에서 시작 커맨드 라인 인자를 지정하려면 다음 단계를 따르십시오.
String UnityPlayerActivity.updateUnityCommandLineArguments(String cmdLine)
메서드를 오버라이드합니다.cmdLine
인자를 자체 시작 인자와 연결한 다음 결과를 반환합니다.
중요: cmdLine
인자는 빈 문자열이거나 null일 수 있으므로 코드가 가능한 값을 처리하도록 해야 합니다.다음 예제는 시작 인자를 지정하여 현재 기기를 기반으로 그래픽스 API를 선택하는 방법을 보여 줍니다.
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);
}
}
커스텀 활동 외에도 다음과 같은 방법으로 커맨드 라인 인자를 지정할 수 있습니다.
adb shell am start -n "<package_name>/<activity_name>" -e unity <command_line_arguments>
다음 예시는 애플리케이션에 -systemallocator
커맨드 라인 인자를 전달하는 방법을 보여 줍니다.
adb shell am start -n "com.Company.MyGame/com.unity3d.player.UnityPlayerActivity" -e unity -systemallocator
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.