Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by freesora · Apr 27, 2012 at 08:38 AM ·

is it possible to use Unity inside wpf

Hi, I would like to make an program using Unity and WPF component.

Basically, The program shows 3d Object using Unity engine inside the frame

which has several components from WPF.

so the main frame is made by "WPF", inside main frame(WPF), we would like to use

unity engine. I've watched some videos from Youtube,

they show me that we are able to use WPF components inside unity program.

it seems like using a special tool, but I have no idea about it

is that possible? if so, how would I like to do this? Thank you =) (Sorry for my English, Eng is my 2nd language, so some grammar mistakes might exist)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image amw157 · Jun 14, 2012 at 03:45 PM 0
Share

I am also looking for the same kind of solution. Have you found anything?

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by RobW81 · Aug 25, 2012 at 08:28 PM

You can do this by getting Unity Handle and setting the Control's handle to Unity's handle with SetParent(). You will also need to call SetWindowLong() to hide the border of the Unity window and you might also need to position the Unity window at the top left of the control by calling MoveWindow().

If you don't know what I mean here is the sample code below. This starts Unity waits for the process to load and parents it to the control UnityPanel which is a Panel. Then removes the boarder from the window and positions Unity at the top left corner of the control. You will want to make sure that you run your game in window mode.

mUnityProcess = Process.Start(mUnityStartInfo); mUnityProcess.WaitForInputIdle(); mUnityHandle = mUnityProcess.MainWindowHandle; SetParent(mUnityProcess.MainWindowHandle, UnityPanel.Handle); SetWindowLong(mUnityHandle, GWL_STYLE, WS_VISIBLE); MoveWindow(mUnityHandle, 0, 0, UnityPanel.ClientSize.Width, UnityPanel.ClientSize.Height, true);

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by lcairco · Aug 13, 2014 at 03:15 PM

Here is another good starting place:

http://stackoverflow.com/questions/6477851/how-to-run-an-application-inside-wpf-application

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Drunken-Monkey · Jun 14, 2012 at 04:23 PM

Are you sure the "Unity" in the video is in fact Unity3D? Microsoft has a .NET product called Unity (contained in PRISM). It has nothing to do with games, but used for dependency injection.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Jun 14, 2012 at 04:24 PM 0
Share

Well you might be able to make the web client run inside a WPF app - using some kind of embedded browser perhaps?

avatar image
0

Answer by Cthaeh23 · Mar 12, 2017 at 07:36 PM

Just in case someone stumbles on this old question like me: I used this custom control: https://www.codeproject.com/Tips/673701/Hosting-EXE-Applications-in-a-WPF-Window-Applicati

But you have to change some code to make everythink work smoothely. To position Unity right (if unity should not be in the upper left corner of youre window):

Point position = this.TranslatePoint(new Point(0f, 0f), Window.GetWindow(this)); MoveWindow(_appWin, (int)(position.X scalingFactor), (int)(position.Y scalingFactor), (int)(ActualWidth scalingFactor), (int)(ActualHeight scalingFactor), true); ´ And to aquiere the handle when unity takes some time to load:

//Wait to aquire handle. _childp.WaitForInputIdle(); while (_childp.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(10); }

For the communication between Unity and WPF I used TcpListener If done right this is fast enough to send data back and forth every frame.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What's my unity version? 1 Answer

Mathf.pingpong 4 Answers

getting high score of game from asp.net page 2 Answers

,Roll a ball - project 0 Answers

Prevent a Character Model to pass through another object 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges