This page describes how to integrate the Unity Runtime Library into Windows and Universal Windows PlatformAn IAP feature that supports Microsoft’s In App Purchase simulator, which allows you to test IAP purchase flows on devices before publishing your application. More info
See in Glossary (UWP) applications using the Unity as a Library feature.
You can use this feature to include Unity-powered features, such as 3D/2D Real-Time RenderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
See in Glossary, ARAugmented Reality (AR) uses computer graphics or video composited on top of a live video feed to augment the view and create interaction with real and virtual objects.
See in Glossary Experience, 3D model interaction, or 2D mini-games, into your application. The Unity Runtime Library exposes controls to manage when and how to load, activate, and unload content within the application.
The UWP XAML project output type makes it easy to create a UWP project that embeds Unity. The generated Visual Studio project is a general XAML UWP project with a SwapChainPanel setup to load the Unity Project. You can extend or replace this Project with any other non-Unity application business logic.
When using a SwapchainPanel, you might want to render over other elements. This enables you to render a small object with a transparent background on top of other non-Unity application content. To do this, enable the PlayerSettings.WSA-transparentSwapchain
option.
You can unload the Unity engine to reclaim resources when Unity is loaded in-process with Application.Unload
.
On Windows, you can embed Unity into your application in two different ways.
The simplest option is to launch Unity as an external process from your application, and specify a window in which Unity will initialize and render with the -parentHWND
command line argument.
The second option is to embed Unity within your existing process. To do this, build Unity into a UnityPlayer.dll
, which can be loaded directly by any Win32 application. The entry point signature is:
extern "C" UNITY_API int UnityMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd);
You can use lpCmdLine
to pass any command line arguments to Unity to control resolution, job threads, parent HWND, etc. This enables you to run Unity within your process. When Unity is not in view, you can use Application.Unload
to reclaim resources it uses.
When hosted by another application, Unity doesn’t control the runtime lifecycle, so it might not work in all scenarios. Known limitations include:
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.