이 페이지에서는 Unity as a Library 기능을 사용하여 Unity 런타임 라이브러리를 Android 애플리케이션에 통합하는 방법을 설명합니다.
이 기능을 통해 3D/2D 실시간 렌더링, AR 경험, 3D 모델 상호작용, 2D 미니 게임 등과 같은 Unity 지원 기능을 애플리케이션에 포함할 수 있습니다. Unity 런타임 라이브러리는 애플리케이션 내에서 콘텐츠를 로드, 활성화 및 언로드하는 시기와 방법을 관리하는 컨트롤을 제공합니다.
중요: 프로젝트를 Unity 2019.4 이상으로 업그레이드하는 경우 Unity as a Library 도입 시 Android에서 올바르게 동작하도록 네이티브 및 관리되는 플러그인을 조정해야 할 수 있습니다. Gradle 매니페스트를 변경하는 플러그인은 네이티브 iOS/Android 앱에서 Unity as a Library 사용에 설명된 Gradle 변경 사항을 사용해야 합니다.
Unity에서 Gradle 프로젝트를 빌드하는 경우 다르게 작업할 필요가 없습니다.
Unity가 생성하는 모든 Android Gradle 프로젝트의 구조는 다음과 같습니다.
Unity를 다른 Android Gradle 프로젝트에 통합하려면 생성된 Android Gradle 프로젝트의 unityLibrary 모듈을 settings.gradle 파일을 통해 Android Unity 프로젝트에 포함해야 합니다.
이 저장소는 Unity를 Android 앱에 통합하는 방법을 설명하는 예제 프로젝트와 플러그인을 상세한 문서와 함께 제공합니다.
플레이어를 제어하려면 Unity 활동의 시작 목적을 릴레이하고 필요한 경우 확장하십시오. 자세한 내용은 목적 및 목적 필터에 대한 Android 개발자 문서를 참조하십시오. 또한 UnityPlayer Java API를 사용할 수도 있습니다.
IUnityPlayerLifecycleEvents는 Unity 플레이어의 두 가지 중요한 라이프사이클 이벤트와 상호작용하기 위한 수단을 제공합니다.
Application.Unload
또는 UnityPlayer.unload()
가 Unity 플레이어를 언로드하면 애플리케이션이 IUnityPlayerLifecycleEvents.onUnityPlayerUnloaded
를 호출합니다. 그러면 Unity 플레이어가 일시정지 상태가 되어 모든 씬을 언로드하지만, 다른 모든 요소는 메모리에 그대로 로드됩니다.IUnityPlayerLifecycleEvents.onUnityPlayerQuitted
를 호출합니다. Unity를 실행 중이던 프로세스는 이 호출 후에 종료됩니다.IUnityPlayerLifecycleEvents
의 인스턴스를 UnityPlayer 생성자에 전달하거나, UnityPlayer
및 UnityPlayerActivity
의 서브 클래스에 있는 메서드를 오버라이드할 수 있습니다.
Unity는 런타임 라이프사이클을 제어하지 않으므로 Unity as a Library 기능이 일부 사례에서 동작하지 않을 수 있습니다. 알려진 제한 사항은 다음과 같습니다.
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.