Update & Workaround:
The problem behind slow debugging with Visual Studio when the LeapMotion plugin is in use stems from the Leap being disconnected. As long as the Leap is connected, everything is fine!
Developers on your team who do not have a Leap can fix it on their end by locally disabling the LeapC.DLL. Select 'LeapC' in your project and in Inspector uncheck the Editor checkbox and restart Unity. Stepping through code should be fast again!
@Leap developers:
Please check whether there is some "is Leap connected?" timeout happening in the native LeapC.dll and whether this timeout can be bypassed or disabled when debugging while there's no leap connected. Maybe check only once in Unity play mode? It's not like people will plug/unplug Leap when the app is running, at least not while developing. Would be great if this timout wouldn't slow down debugging in future releases!
As far as the thread's original problem (Leap.CSharp.NET3.5.DLL causing errors, preventing debugging altogether) is concerned:
I fixed that by using the .NET2.0 DLL posted by Josh. However it had issues of its own (undefined/duplicate symbols) so I simply took the .cs files from this directory in my project, while removing the CSharp.NET DLL altogether. The code lags behind LeapCore 4.2 by 6 months, but fortunately it still works when 2 changes are applied:
ServiceFrameFactory.cs:makeHand, lines 47+ (added LeapQuaternion.Identity parameter):
Hand newHand = new Hand(
(int)owningFrame.Id,
(int)hand.id,
hand.confidence,
hand.grab_strength,
hand.grab_angle,
hand.pinch_strength,
hand.pinch_distance,
hand.palm.width,
hand.type == eLeapHandType.eLeapHandType_Left,
hand.visible_time,
newArm,
new List<Finger>(5),
new Vector(hand.palm.position.x, hand.palm.position.y, hand.palm.position.z),
new Vector(hand.palm.stabilized_position.x, hand.palm.stabilized_position.y, hand.palm.stabilized_position.z),
new Vector(hand.palm.velocity.x, hand.palm.velocity.y, hand.palm.velocity.z),
new Vector(hand.palm.normal.x, hand.palm.normal.y, hand.palm.normal.z),
LeapQuaternion.Identity,
new Vector(hand.palm.direction.x, hand.palm.direction.y, hand.palm.direction.z),
newArm.NextJoint //wrist position
);
CopyFromLeapCExtensions.cs:CopyFrom(), lines 30+ (refactored ArrayElementToStruct call to use out param):
for (int i = frame.Hands.Count; i-- != 0; )
{
LEAP_HAND hand;
StructMarshal<LEAP_HAND>.ArrayElementToStruct(trackingMsg.pHands, i, out hand);
frame.Hands[i].CopyFrom(ref hand, frame.Id);
}
I prefer to have the plugin sources rather than a DLL in my project anyway. It ensures the code is compiled against the correct Unity/framework version and provided that the code is under "Plugins" it doesn't increase recompile time during development either while allowing you to follow any bugs down to 3rd party code if need be.