如何在 wpf winform 中获取 Unity3D 视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17419472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 09:07:29  来源:igfitidea点击:

How get the Unity3D View In wpf winform

c#wpfunity3d

提问by JavaHell

Hi, I'm working in Korean software office and developing android & Unity3D...

嗨,我在韩国软件办公室工作,正在开发 android 和 Unity3D...

I'm want sample code for WPF winform in Viewing Unity3D Project.

我想要查看 Unity3D 项目中 WPF winform 的示例代码。

http://forum.unity3d.com/threads/10855-Unity-in-a-Window/page3, this is reference site. and reference materials.

http://forum.unity3d.com/threads/10855-Unity-in-a-Window/page3,这是参考站点。和参考资料。

For example: If click Button(In WPF), Create object unity3d in wpf viewer.

例如:如果单击按钮(在 WPF 中),则在 wpf 查看器中创建对象 unity3d。

Please help me... I'm want perfect code. Not abstract...

请帮帮我...我想要完美的代码。不抽象...

回答by Ratih Nurmalasari

You can embed your Unity Standalone Application into your WPF application.

您可以将您的 Unity 独立应用程序嵌入到您的 WPF 应用程序中。

  1. Build your unity project into Unity standalone (PC).

  2. Insert WindowsFormsHost in your XAML as a container to load your Unity App.

    <WindowsFormsHost Name="windowsFormsHost" Height="700" Width="1000"/>
    
  3. Create Button in your XAML.

  4. Use ProcessStartInfo to show your Unity Application.

  1. 将您的 Unity 项目构建到 Unity Standalone (PC) 中。

  2. 在您的 XAML 中插入 WindowsFormsHost 作为容器以加载您的 Unity 应用程序。

    <WindowsFormsHost Name="windowsFormsHost" Height="700" Width="1000"/>
    
  3. 在 XAML 中创建按钮。

  4. 使用 ProcessStartInfo 显示您的 Unity 应用程序。