You can use the Unity as a Library feature to integrate the Unity Runtime Library in Windows applications.
This feature enables you to include Unity-powered features in your application, such as:
The Unity Runtime Library exposes controls to manage when and how to load, activate, and unload content within the application.
On Windows, you can embed a Unity build into your application in the following ways:
You can launch Unity as an external build from your application and specify a window in which Unity will initialize and render with the -parentHWND 'HWND' delayed command line argument.
When you pass -parentHWND 'HWND' delayed, the Unity application hides while the command runs. To successfully embed the window, you must:
For an example of a Unity application embedded in a window, refer to the EmbeddedWindow downloadable example.
To resize the Unity window, check its GWLP_USERDATA in Microsoft’s GetWindowLongPtr function:
To embed Unity within your existing operating system process:
Load UnityPlayer.dll directly into your Win32 application.
Call the UnityMain entry point with the following signature:
extern "C" int UnityMain2(HINSTANCE hInst, LPCWSTR customDataFolder, LPWSTR szCmdLine, int nCmdShow);
Pass command line arguments to Unity via the lpCmdLine parameter. You can use this to control settings such as resolution, job threads, or the parent HWND.
For a full list of valid arguments you can pass to lpCmdLine, refer to the Unity Standalone Player command line arguments documentation.