- Home /
Unity and ComImport
Hi,
I'm trying to use ComImport to import a COM+ Interface into Unity and call methods forth and back. The declaration is:
[ComImport, Guid("1A00A7BA-C217-11E0-AC90-0024811441FD"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFTFaceTracker
But for some reason, as soon as I try to ComImport anything, Unity crashes. Anyone has any idea on why, and if Unity is even capable of ComImport? My target deployment environment is only Standalone Windows.
-Roger-
I am wondering the same thing for a project I'm working on. Have you had any luck?
Not at all. I even asked Unity about it, but got no reply from them. What I made now is to make a new .NET Framework 4 application, and used named pipes (could use socket too) to bring data back/forth Unity app. Dumb workaround, but I need to go on, as it seems no one, not even at Unity, knows how to solve it, or even inform if this is not supported by their implementation of $$anonymous$$ono (I'm use 2.6.x version of $$anonymous$$ono in their site can do it perfectly, I tested.)
@zharramadar - what was the support case number? $$anonymous$$y $$anonymous$$m respond to all enquiries, so would be good to look into your case and see what happened.
I'm experiencing this same issue (same library, even) - has anyone found a way around this other than running a separate .NET application and using inter-process communication to shunt the data across?
Answer by Cygon4 · Apr 04, 2013 at 09:19 PM
I'm using ComImport in Unity 4.1.0 to query the Saved Games
folder on Windows systems and I have not noticed any problems so far.
You can find the code I'm using for this in the Unify Community Wiki: Windows Saved Game Directory
If that also crashes Unity for you, it would seem likely that the problem depends on something in your environment. I could imagine that Unity's web player would have trouble because Microsoft has added lots of barriers to calling COM from a browser due to security concerns.
Correction: This only works in the Editor for me. In the standalone player, the first cast (`QueryInterface()`) from COM object to interface fails, just as it would happen if all COM-specific attributes were simply ignored.
Your answer
Follow this Question
Related Questions
Interop Kinect FaceTracking FT_SENSOR_DATA 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Flip over an object (smooth transition) 3 Answers
Simplest way to call c# code from Unity and hook events 3 Answers