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)
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);