Why does VR not work the second time I run the project?
My application doesn't run correctly the second time I run it. I've narrowed down the problem to the LeapMotion DLL (I'm using V2 rather than orion because it has some features that aren't in orion anymore). If I remove it, or don't call it at all, the project works just fine. I'm guessing it may be because Unity doesn't unload managed plugins after running the game in the editor. If I close the editor and reload the project, it will work again.
The VR mode seems to not be able to initialize if the LeapMotion driver is already running. I'm using the latest Oculus drivers and the latest V2 Leap motion driver.
Here are some things I've discovered:
Having the Leap DLL's in the project doesn't break it on its own, it's only if I call new Leap.Controller();. Then, any times I run the project in the editor after that, the VR will not be able to initialize (but the first time I run the project, it does work, even when I make that call).
If I build the project before I run it in the editor, the build will work as many times as I run it. But if I build after I've run the app in the editor, the build will also not work. (This is super weird!)
What I have tried:
I know I can't use
FreeLibrary();
to release the DLL. Apparently, it's not supported by mono.Re-importing the DLL after running the app. (Right click in the project view and then Reimport) doesn't seem to have an effect.
I've tried reimporting the entire project as well. Still no luck.
Made sure I called
controller.Dispose();
on the LeapMotion controller.
I expect if there is some way I could unload the DLL (or maybe reset it to its initial state?) after I stop playing in the editor, then it could start fresh every time.
I've made a repo on GitHub with a simple project file: https://github.com/cameronpenner/LeapV2VR
If anyone has some ideas on how I could get this working I would really appreciate it! Thanks for your time.
Your answer
![](https://koobas.hobune.stream/wayback/20220612090023im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Ray from camera not working in VR? 0 Answers
Unity 5.3.1p3 - Viewports on Render Textures are warped when Virtual Reality Supported is enabled. 0 Answers
How to use Oculus Rift with Unity 5.4.0f3 0 Answers
Mechanics in VR? 0 Answers
Unity 5.2 VR Camera Problem 0 Answers