이 페이지에서는 Unity as a Library 기능을 사용하여 Unity 런타임 라이브러리를 Windows 및 유니버설 Windows 플랫폼(UWP) 애플리케이션에 통합하는 방법을 설명합니다.
이 기능을 통해 3D/2D 실시간 렌더링, AR 경험, 3D 모델 상호작용, 2D 미니 게임 등과 같은 Unity 지원 기능을 애플리케이션에 포함할 수 있습니다. Unity 런타임 라이브러리는 애플리케이션 내에서 콘텐츠를 로드, 활성화 및 언로드하는 시기와 방법을 관리하는 컨트롤을 제공합니다.
UWP XAML 프로젝트 출력 타입을 사용하면 Unity를 포함하는 UWP 프로젝트를 쉽게 만들 수 있습니다. 생성된 Visual Studio 프로젝트는 Unity 프로젝트를 로드하기 위한 SwapChainPanel 설정이 포함된 일반 XAML UWP 프로젝트입니다. 다른 비 Unity 애플리케이션 비즈니스 로직을 사용하여 이 프로젝트를 확장하거나 대체할 수 있습니다.
SwapchainPanel을 사용하는 경우 다른 요소 위에 렌더링해야 할 수 있습니다. 이를 통해 다른 비 Unity 애플리케이션 콘텐츠 위에 투병 배경의 작은 오브젝트를 렌더링할 수 있습니다. 이렇게 하려면 PlayerSettings.WSA-transparentSwapchain
옵션을 활성화하십시오.
Application.Unload
를 사용하여 Unity가 프로세스 중에 로드될 때 Unity 엔진을 언로드하여 리소스를 다시 확보할 수 있습니다.
Windows에서는 다음의 두 가지 방식으로 Unity를 애플리케이션에 포함할 수 있습니다.
가장 간단한 방법은 애플리케이션에서 Unity를 외부 프로세스로 실행하고, Unity가 -parentHWND
커맨드 라인 인자를 사용하여 초기화하고 렌더링할 창을 지정하는 것입니다.
두 번째 옵션은 Unity를 기존 프로세스 내에 포함하는 것입니다. 이렇게 하려면 Unity를 UnityPlayer.dll
로 빌드하십시오. 이 파일은 모든 Win32 애플리케이션에서 직접 로드할 수 있습니다. 엔트리 포인트 서명은 다음과 같습니다.
extern "C" UNITY_API int UnityMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd);
lpCmdLine
을 사용하여 커맨드 라인 인자를 Unity에 전달하여 해상도, 잡 스레드, 부모 HWND 등을 제어할 수 있습니다. 이렇게 하면 프로세스 내에서 Unity를 실행할 수 있습니다. Unity가 뷰 안에 없으면 Application.Unload
를 사용하여 사용 중인 리소스를 다시 확보할 수 있습니다.
다른 애플리케이션에서 호스트된 경우 Unity는 런타임 라이프사이클을 제어하지 않으므로 일부 시나리오에서는 동작하지 않을 수 있습니다. 알려진 제한 사항은 다음과 같습니다.
–
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.