커스텀 Unity 활동을 확장하는 사용 사례는 시작 커맨드 라인 인자를 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 boolean preferES2() {
// Use OpenGL ES 2.0 on devices that run Android 5.1 or older
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1)
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 if (preferES2())
return appendCommandLineArgument(cmdLine, "-force-gles20");
else
return cmdLine; // let Unity pick the Graphics API based on PlayerSettings
}
@Override protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
}
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.