PatHightree / SpaceNavigator

SpaceNavigator driver for Unity3D
MIT License
170 stars 55 forks source link

COM Exception when building with IL2CPP #20

Closed hybridherbst closed 3 years ago

hybridherbst commented 5 years ago

When switching to the new Unity default compiler (IL2CPP) instead of Mono, SpaceNavigator stops working in a Windows build.

There's a COMException thrown:

System.Runtime.InteropServices.COMException (0x80020006): Error HRESULT E_FAIL has been returned from a call to a COM component.
  at TDx.TDxInput.DeviceClass.get_Sensor () [0x00000] in <00000000000000000000000000000000>:0 
  at SpaceNavigatorDriver.SpaceNavigatorWindows..ctor () [0x00000] in <00000000000000000000000000000000>:0 
  at SpaceNavigatorDriver.SpaceNavigatorWindows.get_SubInstance () [0x00000] in <00000000000000000000000000000000>:0 
  at SpaceNavigatorDriver.SpaceNavigator.get_Translation () [0x00000] in <00000000000000000000000000000000>:0 
  at FlyAround.Update () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
SpaceNavigatorDriver.SpaceNavigatorWindows:.ctor()
SpaceNavigatorDriver.SpaceNavigatorWindows:get_SubInstance()
SpaceNavigatorDriver.SpaceNavigator:get_Translation()

Switching back to Mono Scripting Backend makes it work again. Any ideas? What I noted is happening is that Il2CPP packs all .NET DLLs into a "GameAssembly.dll" and calls that. Maybe something checks that the calls are coming from the "right" DLL and prevents access otherwise? Not sure how to make it work in that case...

PatHightree commented 5 years ago

The TDx.TDxInput part comes from a dll by 3DConnexion that I use to interface with the device. Looks like this kind of interfacing is going the way of the dodo. I haven't got any quick fix for this. In the research/3dconnexion-connection branch I've got some research that investigates a new method for interfacing but it's windows-only afaik. It is functional, as in it reads data from the device without the requiring the dll. However, I haven't tested it with IL2CPP! So if anyone's up for it, you can try and integrate it into the master branch. I'm currently tied up in work, other projects and have a vacation coming up, so I won't be working on this project for the foreseeable future.

hybridherbst commented 5 years ago

I see, thank you. Not sure if integrating into the master branch is a good idea if it's not working on Mac yet - do you have numbers how many people are using this on Mac?

I'll try whether that works with IL2CPP though!

PatHightree commented 5 years ago

Yeah, I meant merge the master and research branches, preferably into another branch ;) I've got the package on the unity asset store, but they don't provide any platform-specific data. Only a total downloads number per month, which is always somewhere between 100 and 150. I hear mac-related feedback on a regular basis, so it's safe to assume a sizable portion of the downloads is mac.

tufeixp commented 4 years ago

I tested the research branch, still unable to run on windows 10 il2cpp standalone build!

NotSupportedException: IL2CPP does not support marshaling delegates that point to instance methods to native code. The method we're attempting to marshal is: SpaceNavigatorDriver.SpaceNavigatorWindows::wndProc at SpaceNavigatorDriver.SpaceNavigator.get_Instance () [0x00000] in <00000000000000000000000000000000>:0 at FlyAround.Update () [0x00000] in <00000000000000000000000000000000>:0

PatHightree commented 3 years ago

Closing this issue as with version 2.0.0, the driver has moved away from dll based communication to Unity's new Input System. I succesfully tested a IL2CPP build on Windows.