22// Licensed under the MIT License.
33
44using Microsoft . MixedReality . Toolkit . Utilities ;
5+ using System . Threading . Tasks ;
6+ using UnityEngine ;
57
68#if WINDOWS_UWP
79using Microsoft . MixedReality . Toolkit . Input ;
810using Microsoft . MixedReality . Toolkit . Utilities . Gltf . Serialization ;
911using System ;
1012using System . Collections . Generic ;
11- using System . Threading . Tasks ;
12- using UnityEngine ;
1313using Windows . Storage . Streams ;
1414using Windows . UI . Input . Spatial ;
1515#endif
@@ -32,13 +32,19 @@ public WindowsMixedRealityControllerModelProvider(Handedness handedness)
3232 private readonly SpatialInteractionSource spatialInteractionSource ;
3333
3434 private static readonly Dictionary < string , GameObject > ControllerModelDictionary = new Dictionary < string , GameObject > ( 2 ) ;
35+ #endif // WINDOWS_UWP
3536
37+ // Disables "This async method lacks 'await' operators and will run synchronously." for non-UWP
38+ #pragma warning disable CS1998
3639 /// <summary>
3740 /// Attempts to load the glTF controller model from the Windows SDK.
3841 /// </summary>
3942 /// <returns>The controller model as a GameObject or null if it was unobtainable.</returns>
4043 public async Task < GameObject > TryGenerateControllerModelFromPlatformSDK ( )
4144 {
45+ GameObject gltfGameObject = null ;
46+
47+ #if WINDOWS_UWP
4248 if ( spatialInteractionSource == null )
4349 {
4450 return null ;
@@ -70,7 +76,6 @@ public async Task<GameObject> TryGenerateControllerModelFromPlatformSDK()
7076 }
7177 }
7278
73- GameObject gltfGameObject = null ;
7479 if ( fileBytes != null )
7580 {
7681 Utilities . Gltf . Schema . GltfObject gltfObject = GltfUtility . GetGltfObjectFromGlb ( fileBytes ) ;
@@ -80,10 +85,13 @@ public async Task<GameObject> TryGenerateControllerModelFromPlatformSDK()
8085 ControllerModelDictionary . Add ( GenerateKey ( spatialInteractionSource ) , gltfGameObject ) ;
8186 }
8287 }
88+ #endif // WINDOWS_UWP
8389
8490 return gltfGameObject ;
8591 }
92+ #pragma warning restore CS1998
8693
94+ #if WINDOWS_UWP
8795 private string GenerateKey ( SpatialInteractionSource spatialInteractionSource )
8896 {
8997 return spatialInteractionSource . Controller . VendorId + "/" + spatialInteractionSource . Controller . ProductId + "/" + spatialInteractionSource . Controller . Version + "/" + spatialInteractionSource . Handedness ;
0 commit comments