西姆极客 未分类 Unity Embedded Window

Unity Embedded Window

这个项目基于Unity官方提供的EmbeddedWindow.zip ,利用Unity启动命令参数“-parentHWND delayed (Windows only)”实现Winform嵌入.

关于-parentHWND 的官方解释

Embed the Windows Standalone application into another application. When using this, you need to pass the parent application’s window handle (‘HWND’) to the Windows Standalone application.

When passing -parentHWND ‘HWND’ delayed, the Unity application is hidden while it is running. You must also call SetParent from the Microsoft Developer library for Unity in the application. Microsoft’s SetParent embeds the Unity window. When it creates Unity processes, the Unity window respects the position and size provided as part of the Microsoft’s STARTUPINFO structure.

To resize the Unity window, check its GWLP_USERDATA in Microsoft’s GetWindowLongPtr function. Its lowest bit is set to 1 when graphics have been initialized and it’s safe to resize. Its second lowest bit is set to 1 after the Unity splash screen has finished displaying.
For more information, see this example: EmbeddedWindow.zip

官方下载地址

https://docs.unity.com/uploads/Examples/EmbeddedWindow.zip

这些帖子给了我帮助

Calling Functions on Unity-Application embedded in Winforms-Application

Send message from one program to another in Unity

下载地址:

EmbeddedWindow

发表评论

电子邮件地址不会被公开。 必填项已用*标注

13 + 3 =

Scroll Up