Hi Leap support and anyone that might have run into a similiar problem.
I have in conjunction with a colleague of mine been working on an implementation of the Leap motion hands that should work in a network environment. It's caused us some headache along the way (probably do to our implementation choices) but it seems that we reached a state where it runs.
The reason for the context is that the hands are being synchronized with Unity's built in networking api, which means that each transform in the hands are being updated with a NetworkTransformChild - we've also talked about describing our solution into more detail, if this is of interest?
Because of the synchronization approach we've had to construct our own prefab from the leap tutorial and this has not been a problem, when the application is running in the editor, but we encountered an issue when we built and run it as a stand-alone (As a note this problem also occurred when networking was disabled). The hands relative position is fixed to the initial position of the player prefab (where the leap logic resides) that is instantiated at start.
After a lot of trial and error, testing different approaches we decided to look into the leap source code and we found the root of the problem. In the "LeapVRTemporalWarping" class there is a reference to the "LeapServiceProvider" - 'provider' (which is set in the inspector), which holds a method 'GetLeapController' that returns the "Controller". In our case the controller is 'null' in the provider class and therefore execution exits with a null reference (only in the stand-alone).
To make a long story longer; The 'GetLeapController' method only creates a new "Controller" when it is run in the editor and if you run it anywhere else the reference to the controller is dependent on the "Start" method of "LeapServiceProvider" to be executed before you need this reference.
public Controller GetLeapController() {
#if UNITY_EDITOR
//Null check to deal with hot reloading
if (leap_controller_ == null) {
createController();
}
#endif
return leap_controller_;
}
So my question is: Is there a reason to only check for the leap_controller == null in the editor? Are we missing something essential in this check?
Personally I have only had problems with depending on unity's not controllable order of execution.
We removed the "#if UNITY_EDITOR and things went running smoothly