@@ -41,6 +41,12 @@ static class LeapMotionConfigurationChecker
41
41
// The Leap Unity Modules version 4.7.1 already contains a LeapMotion.asmdef file at this path
42
42
private static string leapAsmDefPath_471 = "LeapMotion/Core/Scripts/LeapMotion.asmdef" ;
43
43
44
+ // This path is used to determine if the Leap Motion Unity Modules is version 4.7.0
45
+ private static string leapTestsPath_470 = "LeapMotion/Core/Editor/Tests" ;
46
+
47
+ // This path is used to determine if the Leap Motion Unity Modules is version 4.6.0 or 4.5.1
48
+ private static string leapXRPath_451 = "LeapMotion/Core/Scripts/XR/LeapXRPinchLocomotion.cs" ;
49
+
44
50
// Array of paths to Leap Motion testing directories that will be removed from the project.
45
51
// Make sure each test directory ends with '/'
46
52
// These paths only need to be deleted if the Leap Core Assets version is 4.4.0
@@ -126,6 +132,8 @@ private static void ConfigureLeapMotion(bool isLeapInProject)
126
132
127
133
if ( isLeapCoreAssetsVersionSupported )
128
134
{
135
+ Debug . Log ( $ "Integrating the Leap Motion Unity Modules Version { currentLeapCoreAssetsVersion } with MRTK") ;
136
+
129
137
RemoveTestingFolders ( ) ;
130
138
AddAndUpdateAsmDefs ( ) ;
131
139
AddLeapEditorAsmDefs ( ) ;
@@ -161,6 +169,32 @@ private static bool LeapCoreAssetsVersionSupport()
161
169
if ( line . Contains ( versionNumberSupported ) )
162
170
{
163
171
currentLeapCoreAssetsVersion = versionNumberSupported ;
172
+
173
+ // The Leap Motion Unity modules Version.txt has remained 4.5.1 across versions 4.6.0, 4.7.0 and 4.7.1, check for the presence
174
+ // of certian paths to infer the version number.
175
+
176
+ // This path is only present in 4.7.1
177
+ string leap471Path = Path . Combine ( Application . dataPath , pathDifference , leapAsmDefPath_471 ) ;
178
+
179
+ // This path is present in versions 4.7.0 and 4.7.1
180
+ string testDirectoryPath = Path . Combine ( Application . dataPath , pathDifference , leapTestsPath_470 ) ;
181
+
182
+ // This path is present in 4.6.0 and not 4.5.1
183
+ string xrPath = Path . Combine ( Application . dataPath , pathDifference , leapXRPath_451 ) ;
184
+
185
+ if ( File . Exists ( leap471Path ) )
186
+ {
187
+ currentLeapCoreAssetsVersion = "4.7.1" ;
188
+ }
189
+ else if ( ! File . Exists ( leap471Path ) && Directory . Exists ( testDirectoryPath ) )
190
+ {
191
+ currentLeapCoreAssetsVersion = "4.7.0" ;
192
+ }
193
+ else if ( ! File . Exists ( leap471Path ) && ! Directory . Exists ( testDirectoryPath ) && File . Exists ( xrPath ) )
194
+ {
195
+ currentLeapCoreAssetsVersion = "4.6.0" ;
196
+ }
197
+
164
198
return true ;
165
199
}
166
200
}
@@ -217,14 +251,9 @@ private static void AddAndUpdateAsmDefs()
217
251
{
218
252
string leapCoreAsmDefPath = Path . Combine ( Application . dataPath , pathDifference , "LeapMotion" , "LeapMotion.asmdef" ) ;
219
253
220
- // The Leap Unity Modules version is 4.7.1 already contains a LeapMotion.asmdef
221
- string leap471Path = Path . Combine ( Application . dataPath , pathDifference , leapAsmDefPath_471 ) ;
222
-
223
- // If the LeapMotion.asmdef is present, then the Leap Unity Modules version is 4.7.1 and the other
224
- // LeapMotion.asmdef file does not need to be created.
225
- if ( File . Exists ( leap471Path ) )
254
+ // If the Leap Unity Modules version is 4.7.1, the LeapMotion.asmdef file does not need to be created
255
+ if ( currentLeapCoreAssetsVersion == "4.7.1" )
226
256
{
227
- currentLeapCoreAssetsVersion = "4.7.1" ;
228
257
return ;
229
258
}
230
259
@@ -243,7 +272,7 @@ private static void AddAndUpdateAsmDefs()
243
272
244
273
// An assembly definition was added to the Leap Core Assets in version 4.5.1
245
274
// The LeapMotion.LeapCSharp assembly definition is added as a reference at the root of the Core Assets
246
- if ( currentLeapCoreAssetsVersion == "4.5.1" )
275
+ if ( currentLeapCoreAssetsVersion == "4.5.1" || currentLeapCoreAssetsVersion == "4.6.0" || currentLeapCoreAssetsVersion == "4.7.0" )
247
276
{
248
277
leapAsmDef . AddReference ( "LeapMotion.LeapCSharp" ) ;
249
278
@@ -290,7 +319,7 @@ private static void AddLeapEditorAsmDefs()
290
319
} ;
291
320
292
321
// Add the LeapMotion.LeapCSharp assembly definition to the leap motion tests assembly definition
293
- if ( ( currentLeapCoreAssetsVersion == "4.5.1" || currentLeapCoreAssetsVersion == "4.7.1" ) && ( leapAsmDef . Key == "LeapMotion.Core.Tests.Editor" || leapAsmDef . Key == "LeapMotion.Core.Editor" ) )
322
+ if ( ( currentLeapCoreAssetsVersion == "4.5.1" || currentLeapCoreAssetsVersion == "4.6.0" || currentLeapCoreAssetsVersion == "4.7.0" || currentLeapCoreAssetsVersion == "4. 7.1") && ( leapAsmDef . Key == "LeapMotion.Core.Tests.Editor" || leapAsmDef . Key == "LeapMotion.Core.Editor" ) )
294
323
{
295
324
leapEditorAsmDef . AddReference ( "LeapMotion.LeapCSharp" ) ;
296
325
}
0 commit comments