Display Unity3D content inside a C# WPF application
Add content to the Unity3D space programmatically from the C# application
Feed information about which objects in the Unity3D model were clicked by the user, back to the C# application (eg. show a message on the WPF form saying “User clicked on cell #xxx”
How can this be done?
Thanks,
-Brendan
P.S. As an aside, I tried posting this in the “Answers” website but continually got “INVALID AUTHORIZATION REQUEST - an error occurred trying to sign in: bad_request”. This happened via two different accounts in both IE, Chrome and Chrome incognito mode. Hence posting it here.
There will be a substantial amount of communication - updates to objects color & location etc and the performance of serialising & deserialising this continuously over an IPC in real time I think would be poor.
Is there any way to make their integation closer eg. expose the Unity3d stuff to the C# application via a DLL?
I doubt it, one of the main reasons, is because your WPF application is running on Microsoft .NET, while Unity child application is running on Mono. So it will be hard to get “close” integration.
I highly doubt the performance of IPC will be your bottleneck.
As for embedding it within a single process: it’s possible, I guess, but I don’t think it will make things easier at all (harder even, if I had to guess). You’d have to P/Invoke to a native DLL from your script, which would in turn load your application in the same process. You’d still have to come up with communication scheme, as you would not be able to directly call WPF land C# from script C# and vice versa.
As far communication is concerned i’m sure we can communicate between 2 applications. I’m also trying to do something similar, but i don’t want to a WPS application to interact with a unity application or .exe. Instead i want to display my game view inside a WPS application then interact with unity.
Is it even possible or do i have to opt-out a different approach?
You can call into UnityPlayer.dll with that command line argument. UnityMain is the entry point function. It takes the same arguments as wWinMain but has cdecl calling convention:
extern "C" __declspec(dllimport) int UnityMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd);