@@ -8,59 +8,78 @@ namespace Microsoft.MixedReality.Toolkit.Core.Utilities
88{
99 public static class PlatformUtility
1010 {
11- public static bool IsPlatformSupported ( this RuntimePlatform runtimePlatform , SupportedPlatforms platform )
11+ public static bool IsPlatformSupported ( this RuntimePlatform runtimePlatform , SupportedPlatforms platforms )
1212 {
13- if ( platform == ( SupportedPlatforms ) ( - 1 ) )
14- {
15- return true ;
16- }
13+ SupportedPlatforms target = GetSupportedPlatformMask ( runtimePlatform ) ;
14+ return IsPlatformSupported ( target , platforms ) ;
15+ }
16+
17+ private static SupportedPlatforms GetSupportedPlatformMask ( RuntimePlatform runtimePlatform )
18+ {
19+ SupportedPlatforms supportedPlatforms = 0 ;
1720
1821 switch ( runtimePlatform )
1922 {
2023 case RuntimePlatform . WindowsPlayer :
2124 case RuntimePlatform . WindowsEditor :
22- return ( platform & SupportedPlatforms . WindowsStandalone ) != 0 ;
25+ supportedPlatforms |= SupportedPlatforms . WindowsStandalone ;
26+ break ;
2327 case RuntimePlatform . WSAPlayerARM :
2428 case RuntimePlatform . WSAPlayerX86 :
2529 case RuntimePlatform . WSAPlayerX64 :
2630 case RuntimePlatform . XboxOne :
27- return ( platform & SupportedPlatforms . WindowsUniversal ) != 0 ;
28- case RuntimePlatform . OSXEditor :
31+ supportedPlatforms |= SupportedPlatforms . WindowsUniversal ;
32+ break ;
2933 case RuntimePlatform . OSXPlayer :
30- return ( platform & SupportedPlatforms . MacStandalone ) != 0 ;
34+ case RuntimePlatform . OSXEditor :
35+ supportedPlatforms |= SupportedPlatforms . MacStandalone ;
36+ break ;
3137 case RuntimePlatform . LinuxPlayer :
3238 case RuntimePlatform . LinuxEditor :
33- return ( platform & SupportedPlatforms . LinuxStandalone ) != 0 ;
34- default :
35- return false ;
39+ supportedPlatforms |= SupportedPlatforms . LinuxStandalone ;
40+ break ;
3641 }
42+
43+ return supportedPlatforms ;
44+ }
45+
46+ private static bool IsPlatformSupported ( SupportedPlatforms target , SupportedPlatforms supported )
47+ {
48+ return ( ( target & supported ) == target ) ;
3749 }
3850
3951#if UNITY_EDITOR
40- public static bool IsPlatformSupported ( this UnityEditor . BuildTarget editorBuildTarget , SupportedPlatforms platform )
52+ public static bool IsPlatformSupported ( this UnityEditor . BuildTarget editorBuildTarget , SupportedPlatforms platforms )
4153 {
42- if ( platform == ( SupportedPlatforms ) ( - 1 ) )
43- {
44- return true ;
45- }
54+ SupportedPlatforms target = GetSupportedPlatformMask ( editorBuildTarget ) ;
55+ return IsPlatformSupported ( target , platforms ) ;
56+ }
57+
58+ private static SupportedPlatforms GetSupportedPlatformMask ( UnityEditor . BuildTarget editorBuildTarget )
59+ {
60+ SupportedPlatforms supportedPlatforms = 0 ;
4661
4762 switch ( editorBuildTarget )
4863 {
4964 case UnityEditor . BuildTarget . StandaloneWindows :
5065 case UnityEditor . BuildTarget . StandaloneWindows64 :
51- return ( platform & SupportedPlatforms . WindowsStandalone ) != 0 ;
66+ supportedPlatforms |= SupportedPlatforms . WindowsStandalone ;
67+ break ;
5268 case UnityEditor . BuildTarget . WSAPlayer :
5369 case UnityEditor . BuildTarget . XboxOne :
54- return ( platform & SupportedPlatforms . WindowsUniversal ) != 0 ;
70+ supportedPlatforms |= SupportedPlatforms . WindowsUniversal ;
71+ break ;
5572 case UnityEditor . BuildTarget . StandaloneOSX :
56- return ( platform & SupportedPlatforms . MacStandalone ) != 0 ;
73+ supportedPlatforms |= SupportedPlatforms . MacStandalone ;
74+ break ;
5775 case UnityEditor . BuildTarget . StandaloneLinux :
5876 case UnityEditor . BuildTarget . StandaloneLinux64 :
5977 case UnityEditor . BuildTarget . StandaloneLinuxUniversal :
60- return ( platform & SupportedPlatforms . LinuxStandalone ) != 0 ;
61- default :
62- return false ;
78+ supportedPlatforms |= SupportedPlatforms . LinuxStandalone ;
79+ break ;
6380 }
81+
82+ return supportedPlatforms ;
6483 }
6584#endif
6685 }
0 commit comments