2
2
// Licensed under the MIT License.
3
3
4
4
using Microsoft . MixedReality . Toolkit . Utilities ;
5
+ using System . Threading . Tasks ;
6
+ using UnityEngine ;
5
7
6
8
#if WINDOWS_UWP
7
9
using Microsoft . MixedReality . Toolkit . Input ;
8
10
using Microsoft . MixedReality . Toolkit . Utilities . Gltf . Serialization ;
9
11
using System ;
10
12
using System . Collections . Generic ;
11
- using System . Threading . Tasks ;
12
- using UnityEngine ;
13
13
using Windows . Storage . Streams ;
14
14
using Windows . UI . Input . Spatial ;
15
15
#endif
@@ -32,13 +32,19 @@ public WindowsMixedRealityControllerModelProvider(Handedness handedness)
32
32
private readonly SpatialInteractionSource spatialInteractionSource ;
33
33
34
34
private static readonly Dictionary < string , GameObject > ControllerModelDictionary = new Dictionary < string , GameObject > ( 2 ) ;
35
+ #endif // WINDOWS_UWP
35
36
37
+ // Disables "This async method lacks 'await' operators and will run synchronously." for non-UWP
38
+ #pragma warning disable CS1998
36
39
/// <summary>
37
40
/// Attempts to load the glTF controller model from the Windows SDK.
38
41
/// </summary>
39
42
/// <returns>The controller model as a GameObject or null if it was unobtainable.</returns>
40
43
public async Task < GameObject > TryGenerateControllerModelFromPlatformSDK ( )
41
44
{
45
+ GameObject gltfGameObject = null ;
46
+
47
+ #if WINDOWS_UWP
42
48
if ( spatialInteractionSource == null )
43
49
{
44
50
return null ;
@@ -70,7 +76,6 @@ public async Task<GameObject> TryGenerateControllerModelFromPlatformSDK()
70
76
}
71
77
}
72
78
73
- GameObject gltfGameObject = null ;
74
79
if ( fileBytes != null )
75
80
{
76
81
Utilities . Gltf . Schema . GltfObject gltfObject = GltfUtility . GetGltfObjectFromGlb ( fileBytes ) ;
@@ -80,10 +85,13 @@ public async Task<GameObject> TryGenerateControllerModelFromPlatformSDK()
80
85
ControllerModelDictionary . Add ( GenerateKey ( spatialInteractionSource ) , gltfGameObject ) ;
81
86
}
82
87
}
88
+ #endif // WINDOWS_UWP
83
89
84
90
return gltfGameObject ;
85
91
}
92
+ #pragma warning restore CS1998
86
93
94
+ #if WINDOWS_UWP
87
95
private string GenerateKey ( SpatialInteractionSource spatialInteractionSource )
88
96
{
89
97
return spatialInteractionSource . Controller . VendorId + "/" + spatialInteractionSource . Controller . ProductId + "/" + spatialInteractionSource . Controller . Version + "/" + spatialInteractionSource . Handedness ;
0 commit comments