@@ -120,7 +120,7 @@ public static bool TryGetBuildTarget(BuildTarget platform, out IBuildTarget buil
120
120
return buildTarget != null ;
121
121
}
122
122
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
124
124
{
125
125
if ( TryGetBuildTarget ( platform , out var buildTarget ) )
126
126
{
@@ -255,6 +255,24 @@ internal static bool DoesBuildTargetSupportSinglePassStereoRendering(BuildTarget
255
255
s_platform_102 ,
256
256
} ;
257
257
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
+
258
276
static GUID [ ] MacBuildTargets { get ; } = new GUID [ ]
259
277
{
260
278
s_platform_02 ,
@@ -490,7 +508,7 @@ static BuildTargetDiscovery()
490
508
491
509
public static GUID GetGUIDFromBuildTarget ( BuildTarget buildTarget )
492
510
{
493
- if ( s_PlatformGUIDData . TryGetValue ( buildTarget , out GUID value ) )
511
+ if ( s_PlatformGUIDData . TryGetValue ( buildTarget , out GUID value ) )
494
512
return value ;
495
513
496
514
return new GUID ( "" ) ;
@@ -615,53 +633,40 @@ public static bool BuildPlatformIsInstalled(GUID platformGuid)
615
633
}
616
634
617
635
[ 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 ) ;
618
638
619
- public static bool BuildPlatformIsAvailableOnHostPlatform ( BuildTarget platform , UnityEngine . OperatingSystemFamily hostPlatform )
639
+ public static bool BuildPlatformIsAvailableOnHostPlatform ( GUID platformGuid , UnityEngine . OperatingSystemFamily hostPlatform )
620
640
{
621
- var platformGuid = GetGUIDFromBuildTarget ( platform ) ;
641
+ var platformTargetArray = WindowsBuildTargets ;
622
642
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 ;
629
645
else if ( hostPlatform == UnityEngine . OperatingSystemFamily . MacOSX )
630
- {
631
- foreach ( var macTarget in MacBuildTargets )
632
- if ( macTarget == platformGuid )
633
- return true ;
634
- }
646
+ platformTargetArray = MacBuildTargets ;
635
647
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
+
641
654
return false ;
642
655
}
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 ;
655
656
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 ;
660
664
661
- return false ;
665
+ architecture = architecture . ToLowerInvariant ( ) ;
666
+ return architecture . Contains ( "arm64" ) || architecture . Contains ( "aarch64" ) ;
662
667
}
663
- [ System . Obsolete ( "BuildPlatformCanBeInstalledWithHub(BuildTarget) is obsolete. Use BuildPlatformCanBeInstalledWithHub(IBuildTarget) instead." , false ) ]
664
668
669
+ [ System . Obsolete ( "BuildPlatformCanBeInstalledWithHub(BuildTarget) is obsolete. Use BuildPlatformCanBeInstalledWithHub(IBuildTarget) instead." , false ) ]
665
670
public static bool BuildPlatformCanBeInstalledWithHub ( BuildTarget platform )
666
671
{
667
672
foreach ( var target in ExternalDownloadForBuildTarget )
0 commit comments