@@ -30,14 +30,23 @@ static class LeapMotionConfigurationChecker
30
30
private static bool isLeapRecognizedByMRTK = false ;
31
31
32
32
// The current supported Leap Core Assets version numbers.
33
- private static string [ ] leapCoreAssetsVersionsSupported = new string [ ] { "4.5.0" , "4.5.1" } ;
33
+ private static string [ ] leapCoreAssetsVersionsSupported = new string [ ] { "4.5.0" , "4.5.1" , "4.6.0" , "4.7.0" , "4.7.1" } ;
34
34
35
35
// The current Leap Core Assets version in this project
36
36
private static string currentLeapCoreAssetsVersion = "" ;
37
37
38
38
// The path difference between the root of assets and the root of the Leap Motion Core Assets.
39
39
private static string pathDifference = "" ;
40
40
41
+ // The Leap Unity Modules version 4.7.1 already contains a LeapMotion.asmdef file at this path
42
+ private static string leapAsmDefPath_471 = "LeapMotion/Core/Scripts/LeapMotion.asmdef" ;
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_460 = "LeapMotion/Core/Scripts/XR/LeapXRPinchLocomotion.cs" ;
49
+
41
50
// Array of paths to Leap Motion testing directories that will be removed from the project.
42
51
// Make sure each test directory ends with '/'
43
52
// These paths only need to be deleted if the Leap Core Assets version is 4.4.0
@@ -123,6 +132,8 @@ private static void ConfigureLeapMotion(bool isLeapInProject)
123
132
124
133
if ( isLeapCoreAssetsVersionSupported )
125
134
{
135
+ Debug . Log ( $ "Integrating the Leap Motion Unity Modules Version { currentLeapCoreAssetsVersion } with MRTK") ;
136
+
126
137
RemoveTestingFolders ( ) ;
127
138
AddAndUpdateAsmDefs ( ) ;
128
139
AddLeapEditorAsmDefs ( ) ;
@@ -158,6 +169,32 @@ private static bool LeapCoreAssetsVersionSupport()
158
169
if ( line . Contains ( versionNumberSupported ) )
159
170
{
160
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 certain 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_460 ) ;
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
+
161
198
return true ;
162
199
}
163
200
}
@@ -214,6 +251,12 @@ private static void AddAndUpdateAsmDefs()
214
251
{
215
252
string leapCoreAsmDefPath = Path . Combine ( Application . dataPath , pathDifference , "LeapMotion" , "LeapMotion.asmdef" ) ;
216
253
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" )
256
+ {
257
+ return ;
258
+ }
259
+
217
260
// If the asmdef has already been created then do not create another one
218
261
if ( ! File . Exists ( leapCoreAsmDefPath ) )
219
262
{
@@ -229,9 +272,14 @@ private static void AddAndUpdateAsmDefs()
229
272
230
273
// An assembly definition was added to the Leap Core Assets in version 4.5.1
231
274
// The LeapMotion.LeapCSharp assembly definition is added as a reference at the root of the Core Assets
232
- if ( currentLeapCoreAssetsVersion == "4.5.1" )
275
+ if ( currentLeapCoreAssetsVersion == "4.5.1" || currentLeapCoreAssetsVersion == "4.6.0" || currentLeapCoreAssetsVersion == "4.7.0" )
233
276
{
234
277
leapAsmDef . AddReference ( "LeapMotion.LeapCSharp" ) ;
278
+
279
+ // If the unity modules version is 4.6.0 or 4.7.0 then add SpatialTracking as a reference
280
+ #if UNITY_2019_3_OR_NEWER
281
+ leapAsmDef . AddReference ( "UnityEngine.SpatialTracking" ) ;
282
+ #endif
235
283
}
236
284
237
285
leapAsmDef . Save ( leapCoreAsmDefPath ) ;
@@ -271,7 +319,7 @@ private static void AddLeapEditorAsmDefs()
271
319
} ;
272
320
273
321
// Add the LeapMotion.LeapCSharp assembly definition to the leap motion tests assembly definition
274
- if ( currentLeapCoreAssetsVersion == "4.5.1" && leapAsmDef . Key == "LeapMotion.Core.Tests.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" ) )
275
323
{
276
324
leapEditorAsmDef . AddReference ( "LeapMotion.LeapCSharp" ) ;
277
325
}
0 commit comments