@@ -120,7 +120,7 @@ public static bool TryGetBuildTarget(BuildTarget platform, out IBuildTarget buil
120120 return buildTarget != null ;
121121 }
122122
123- public static bool TryGetProperties < T > ( BuildTarget platform , out T properties ) where T : IPlatformProperties
123+ public static bool TryGetProperties < T > ( BuildTarget platform , out T properties ) where T : IPlatformProperties
124124 {
125125 if ( TryGetBuildTarget ( platform , out var buildTarget ) )
126126 {
@@ -255,6 +255,24 @@ internal static bool DoesBuildTargetSupportSinglePassStereoRendering(BuildTarget
255255 s_platform_102 ,
256256 } ;
257257
258+ static GUID [ ] WindowsARM64BuildTargets { get ; } = new GUID [ ]
259+ {
260+ s_platform_02 ,
261+ s_platform_05 ,
262+ s_platform_09 ,
263+ s_platform_13 ,
264+ s_platform_20 ,
265+ s_platform_21 ,
266+ s_platform_24 ,
267+ s_platform_37 ,
268+ s_platform_41 ,
269+ s_platform_46 ,
270+ s_platform_47 ,
271+ s_platform_100 ,
272+ s_platform_101 ,
273+ s_platform_102 ,
274+ } ;
275+
258276 static GUID [ ] MacBuildTargets { get ; } = new GUID [ ]
259277 {
260278 s_platform_02 ,
@@ -490,7 +508,7 @@ static BuildTargetDiscovery()
490508
491509 public static GUID GetGUIDFromBuildTarget ( BuildTarget buildTarget )
492510 {
493- if ( s_PlatformGUIDData . TryGetValue ( buildTarget , out GUID value ) )
511+ if ( s_PlatformGUIDData . TryGetValue ( buildTarget , out GUID value ) )
494512 return value ;
495513
496514 return new GUID ( "" ) ;
@@ -615,53 +633,40 @@ public static bool BuildPlatformIsInstalled(GUID platformGuid)
615633 }
616634
617635 [ System . Obsolete ( "BuildPlatformIsAvailableOnHostPlatform(BuildTarget) is obsolete. Use BuildPlatformIsAvailableOnHostPlatform(IBuildTarget) instead." , false ) ]
636+ public static bool BuildPlatformIsAvailableOnHostPlatform ( BuildTarget platform , UnityEngine . OperatingSystemFamily hostPlatform ) => BuildPlatformIsAvailableOnHostPlatform ( GetGUIDFromBuildTarget ( platform ) , hostPlatform ) ;
637+ public static bool BuildPlatformIsAvailableOnHostPlatform ( IBuildTarget platform , UnityEngine . OperatingSystemFamily hostPlatform ) => BuildPlatformIsAvailableOnHostPlatform ( platform . Guid , hostPlatform ) ;
618638
619- public static bool BuildPlatformIsAvailableOnHostPlatform ( BuildTarget platform , UnityEngine . OperatingSystemFamily hostPlatform )
639+ public static bool BuildPlatformIsAvailableOnHostPlatform ( GUID platformGuid , UnityEngine . OperatingSystemFamily hostPlatform )
620640 {
621- var platformGuid = GetGUIDFromBuildTarget ( platform ) ;
641+ var platformTargetArray = WindowsBuildTargets ;
622642
623- if ( hostPlatform == UnityEngine . OperatingSystemFamily . Windows )
624- {
625- foreach ( var winTarget in WindowsBuildTargets )
626- if ( winTarget == platformGuid )
627- return true ;
628- }
643+ if ( hostPlatform == UnityEngine . OperatingSystemFamily . Windows && IsWindowsArm64Architecture ( ) )
644+ platformTargetArray = WindowsARM64BuildTargets ;
629645 else if ( hostPlatform == UnityEngine . OperatingSystemFamily . MacOSX )
630- {
631- foreach ( var macTarget in MacBuildTargets )
632- if ( macTarget == platformGuid )
633- return true ;
634- }
646+ platformTargetArray = MacBuildTargets ;
635647 else if ( hostPlatform == UnityEngine . OperatingSystemFamily . Linux )
636- {
637- foreach ( var linuxTarget in LinuxBuildTargets )
638- if ( linuxTarget == platformGuid )
639- return true ;
640- }
648+ platformTargetArray = LinuxBuildTargets ;
649+
650+ foreach ( var platformTarget in platformTargetArray )
651+ if ( platformTarget == platformGuid )
652+ return true ;
653+
641654 return false ;
642655 }
643- public static bool BuildPlatformIsAvailableOnHostPlatform ( IBuildTarget platform , UnityEngine . OperatingSystemFamily hostPlatform )
644- {
645- // TODO: PLAT-8695 - Consoles are available only on x64 Windows. They can't build on Arm64. Windows.x64 and arm64 have different compability in platforms
646- if ( hostPlatform == UnityEngine . OperatingSystemFamily . Windows )
647- foreach ( var winTarget in WindowsBuildTargets )
648- if ( winTarget == platform . Guid )
649- return true ;
650-
651- else if ( hostPlatform == UnityEngine . OperatingSystemFamily . MacOSX )
652- foreach ( var macTarget in MacBuildTargets )
653- if ( macTarget == platform . Guid )
654- return true ;
655656
656- else if ( hostPlatform == UnityEngine . OperatingSystemFamily . Linux )
657- foreach ( var linuxTarget in LinuxBuildTargets )
658- if ( linuxTarget == platform . Guid )
659- return true ;
657+ static bool IsWindowsArm64Architecture ( )
658+ {
659+ // Based on WindowsUtility.GetHostOSArchitecture() in platform dependent code
660+ // We can't use RuntimeInformation.OSArchitecture because it doesn't work on emulations
661+ var architecture = Environment . GetEnvironmentVariable ( "PROCESSOR_ARCHITECTURE" , EnvironmentVariableTarget . Machine ) ;
662+ if ( string . IsNullOrEmpty ( architecture ) )
663+ return false ;
660664
661- return false ;
665+ architecture = architecture . ToLowerInvariant ( ) ;
666+ return architecture . Contains ( "arm64" ) || architecture . Contains ( "aarch64" ) ;
662667 }
663- [ System . Obsolete ( "BuildPlatformCanBeInstalledWithHub(BuildTarget) is obsolete. Use BuildPlatformCanBeInstalledWithHub(IBuildTarget) instead." , false ) ]
664668
669+ [ System . Obsolete ( "BuildPlatformCanBeInstalledWithHub(BuildTarget) is obsolete. Use BuildPlatformCanBeInstalledWithHub(IBuildTarget) instead." , false ) ]
665670 public static bool BuildPlatformCanBeInstalledWithHub ( BuildTarget platform )
666671 {
667672 foreach ( var target in ExternalDownloadForBuildTarget )
0 commit comments