@@ -22,41 +22,23 @@ internal class BuildProfileModuleUtil
2222    { 
2323        const  string  k_BuyProUrl  =  "https://store.unity.com/products/unity-pro" ; 
2424        const  string  k_ConsoleModuleUrl  =  "https://unity3d.com/platform-installation" ; 
25-         const  string  k_BuildSettingsPlatformIconFormat  =  "BuildSettings.{0}" ; 
2625        const  string  k_LastRunnableBuildPathSeparator  =  "_" ; 
2726        static readonly  string  k_NoModuleLoaded  =  L10n . Tr ( "No {0} module loaded." ) ; 
2827        static readonly  string  k_EditorWillNeedToBeReloaded  =  L10n . Tr ( "Note: Editor will need to be restarted to load any newly installed modules" ) ; 
2928        static readonly  string  k_BuildProfileRecompileReason  =  L10n . Tr ( "Active build profile scripting defines changes." ) ; 
3029        static readonly  GUIContent  k_OpenDownloadPage  =  EditorGUIUtility . TrTextContent ( "Open Download Page" ) ; 
3130        static readonly  GUIContent  k_InstallModuleWithHub  =  EditorGUIUtility . TrTextContent ( "Install with Unity Hub" ) ; 
32-         static Dictionary < string ,  BuildTargetDiscovery . DiscoveredTargetInfo >  s_DiscoveredTargetInfos  =  InitializeDiscoveredTargetDict ( ) ; 
3331        static HashSet < string >  s_BuildProfileIconModules  =  new ( ) 
3432        { 
3533            "Switch" , 
3634            "QNX" , 
3735        } ; 
3836
3937        /// <summary> 
40-         /// Classic platform display name for a given build profile. Matching 
41-         /// value in the old BuildSettings window. 
38+         /// Classic platform display name for a given build profile. 
4239        /// </summary> 
43-         /// <see cref="BuildPlayerWindow"/> 
44-         public  static string  GetClassicPlatformDisplayName ( string  platformId ) 
45-         { 
46-             var  ( buildTarget ,  subtarget )  =  GetBuildTargetAndSubtarget ( platformId ) ; 
47-             var  moduleName  =  GetModuleName ( buildTarget ) ; 
48- 
49-             return  ( moduleName ,  subtarget )  switch 
50-             { 
51-                 ( "OSXStandalone" ,  StandaloneBuildSubtarget . Server )  =>  "Mac Server" , 
52-                 ( "WindowsStandalone" ,  StandaloneBuildSubtarget . Server )  =>  "Windows Server" , 
53-                 ( "LinuxStandalone" ,  StandaloneBuildSubtarget . Server )  =>  "Linux Server" , 
54-                 ( "OSXStandalone" ,  _ )  =>  "Mac" , 
55-                 ( "WindowsStandalone" ,  _ )  =>  "Windows" , 
56-                 ( "LinuxStandalone" ,  _ )  =>  "Linux" , 
57-                 _ =>  GetModuleDisplayName ( moduleName ) , 
58-             } ; 
59-         } 
40+         public  static string  GetClassicPlatformDisplayName ( string  platformId )  => 
41+             GetModuleDisplayName ( platformId ) ; 
6042
6143        /// <summary> 
6244        /// Fetch default editor platform icon texture. 
@@ -102,25 +84,10 @@ public static Texture2D GetWarningIcon()
10284        /// </summary> 
10385        public  static bool  IsModuleInstalled ( string  platformId ) 
10486        { 
105-             var  ( buildTarget ,  subtarget )  =  GetBuildTargetAndSubtarget ( platformId ) ; 
87+             var  ( buildTarget ,  _ )  =  GetBuildTargetAndSubtarget ( platformId ) ; 
10688            var  moduleName  =  GetModuleName ( buildTarget ) ; 
10789
108-             // NamedBuildTarget will be deprecated. This code is extracted from 
109-             // NamedBuildTarget.FromActiveSettings. Except instead of taking a dependency 
110-             // on Editor User Build Settings, we use the passed subtarget. 
111-             NamedBuildTarget  namedTarget ; 
112-             var  buildTargetGroup  =  BuildPipeline . GetBuildTargetGroup ( buildTarget ) ; 
113-             if  ( buildTargetGroup  ==  BuildTargetGroup . Standalone 
114-                 &&  subtarget  ==  StandaloneBuildSubtarget . Server ) 
115-             { 
116-                 namedTarget  =  NamedBuildTarget . Server ; 
117-             } 
118-             else 
119-             { 
120-                 namedTarget  =  NamedBuildTarget . FromBuildTargetGroup ( buildTargetGroup ) ; 
121-             } 
122- 
123-             bool  installed  =  BuildPlatforms . instance . BuildPlatformFromNamedBuildTarget ( namedTarget ) . installed ; 
90+             bool  installed  =  BuildTargetDiscovery . BuildPlatformIsInstalled ( new  GUID ( platformId ) ) ; 
12491            return  installed 
12592                &&  BuildPipeline . LicenseCheck ( buildTarget ) 
12693                &&  ! string . IsNullOrEmpty ( moduleName ) 
@@ -168,9 +135,7 @@ public static VisualElement CreateLicenseNotFoundElement(string platformId)
168135            if  ( BuildPipeline . LicenseCheck ( buildTarget ) ) 
169136                return  null ; 
170137
171-             var  targetGroup  =  BuildPipeline . GetBuildTargetGroup ( buildTarget ) ; 
172-             var  namedBuildTarget  =  NamedBuildTarget . FromBuildTargetGroup ( targetGroup ) ; 
173-             string  niceName  =  BuildPipeline . GetBuildTargetGroupDisplayName ( namedBuildTarget . ToBuildTargetGroup ( ) ) ; 
138+             string  displayName  =  GetModuleDisplayName ( platformId ) ; 
174139            string  licenseMsg  =  L10n . Tr ( "Your license does not cover {0} Publishing." ) ; 
175140            string  buttonMsg  =  L10n . Tr ( "Go to Our Online Store" ) ; 
176141            string  url  =  k_BuyProUrl ; 
@@ -184,7 +149,7 @@ public static VisualElement CreateLicenseNotFoundElement(string platformId)
184149
185150            var  root  =  new  VisualElement ( ) ; 
186151            root . style . flexDirection  =  FlexDirection . Column ; 
187-             var  label  =  new  Label ( string . Format ( licenseMsg ,  niceName ) ) ; 
152+             var  label  =  new  Label ( string . Format ( licenseMsg ,  displayName ) ) ; 
188153            label . style . whiteSpace  =  WhiteSpace . Normal ; 
189154            root . Add ( label ) ; 
190155            if  ( ! BuildTargetDiscovery . PlatformHasFlag ( buildTarget ,  TargetAttributes . IsStandalonePlatform ) ) 
@@ -341,36 +306,23 @@ public static IBuildProfileExtension GetBuildProfileExtension(string moduleName)
341306        /// </summary> 
342307        public  static List < string >  FindAllViewablePlatforms ( ) 
343308        { 
344-             var  result  =  new  List < string > ( ) 
309+             var  result  =  new  List < string > ( ) ; 
310+ 
311+             foreach  ( var  platformGuid  in  BuildTargetDiscovery . GetAllPlatforms ( ) ) 
345312            { 
346-                 GetPlatformId ( BuildTarget . StandaloneWindows64 ,  StandaloneBuildSubtarget . Player ) , 
347-                 GetPlatformId ( BuildTarget . StandaloneOSX ,  StandaloneBuildSubtarget . Player ) , 
348-                 GetPlatformId ( BuildTarget . StandaloneLinux64 ,  StandaloneBuildSubtarget . Player ) , 
349-                 GetPlatformId ( BuildTarget . StandaloneWindows64 ,  StandaloneBuildSubtarget . Server ) , 
350-                 GetPlatformId ( BuildTarget . StandaloneOSX ,  StandaloneBuildSubtarget . Server ) , 
351-                 GetPlatformId ( BuildTarget . StandaloneLinux64 ,  StandaloneBuildSubtarget . Server ) 
352-             } ; 
313+                 var  installed  =  BuildTargetDiscovery . BuildPlatformIsInstalled ( platformGuid ) ; 
314+                 if  ( ! installed  &&  BuildTargetDiscovery . BuildPlatformIsHiddenInUI ( platformGuid ) ) 
315+                     continue ; 
316+ 
317+                 result . Add ( platformGuid . ToString ( ) ) ; 
318+             } 
353319
354320            // Swap current editor standalone platform to the top. 
355321            if  ( Application . platform  ==  RuntimePlatform . OSXEditor ) 
356322                result . Reverse ( 0 ,  2 ) ; 
357323            if  ( Application . platform  ==  RuntimePlatform . LinuxEditor ) 
358324                result . Reverse ( 0 ,  3 ) ; 
359325
360-             foreach  ( var  buildTargetInfo  in  BuildTargetDiscovery . GetBuildTargetInfoList ( ) ) 
361-             { 
362-                 if  ( buildTargetInfo . HasFlag ( TargetAttributes . IsStandalonePlatform ) ) 
363-                     continue ; 
364- 
365-                 // installed platform check from BuildPlatforms 
366-                 bool  installed  =  BuildPipeline . GetPlaybackEngineDirectory ( buildTargetInfo . buildTargetPlatformVal ,  BuildOptions . None ,  false )  !=  string . Empty ; 
367-                 if  ( ! installed  &&  buildTargetInfo . HasFlag ( TargetAttributes . HideInUI ) ) 
368-                     continue ; 
369- 
370-                 var  platformId  =  GetPlatformId ( buildTargetInfo . buildTargetPlatformVal ,  StandaloneBuildSubtarget . Default ) ; 
371-                 result . Add ( platformId ) ; 
372-             } 
373- 
374326            return  result ; 
375327        } 
376328
@@ -542,17 +494,6 @@ internal static void SetBuildProfileLastRunnableBuildPathKey(string key, string
542494            EditorPrefs . SetString ( key ,  value ) ; 
543495        } 
544496
545-         static Dictionary < string ,  BuildTargetDiscovery . DiscoveredTargetInfo >  InitializeDiscoveredTargetDict ( ) 
546-         { 
547-             var  result  =  new  Dictionary < string ,  BuildTargetDiscovery . DiscoveredTargetInfo > ( ) ; 
548-             foreach  ( var  kvp  in  BuildTargetDiscovery . GetBuildTargetInfoList ( ) ) 
549-             { 
550-                 var  targetString  =  GetModuleName ( kvp . buildTargetPlatformVal ) ; 
551-                 result . TryAdd ( targetString ,  kvp ) ; 
552-             } 
553-             return  result ; 
554-         } 
555- 
556497        static bool  LoadBuildProfileIcon ( string  platformId ,  out  Texture2D  icon ) 
557498        { 
558499            var  moduleName  =  GetModuleName ( platformId ) ; 
@@ -568,31 +509,17 @@ static bool LoadBuildProfileIcon(string platformId, out Texture2D icon)
568509
569510        static string  GetPlatformIconId ( string  platformId ) 
570511        { 
571-             var  ( buildTarget ,  subtarget )  =  GetBuildTargetAndSubtarget ( platformId ) ; 
572-             var  moduleName  =  GetModuleName ( buildTarget ) ; 
573- 
574-             if  ( subtarget  ==  StandaloneBuildSubtarget . Server ) 
575-             { 
576-                 return  string . Format ( k_BuildSettingsPlatformIconFormat ,  "DedicatedServer" ) ; 
577-             } 
512+             var  iconName  =  BuildTargetDiscovery . BuildPlatformIconName ( new  GUID ( platformId ) ) ; 
578513
579-             if  ( s_DiscoveredTargetInfos . TryGetValue ( moduleName ,  out  var  targetInfo ) ) 
580-             { 
581-                 return  targetInfo . iconName ; 
582-             } 
514+             if  ( string . IsNullOrEmpty ( iconName ) ) 
515+                 return  "BuildSettings.Editor" ; 
583516
584-             return  "BuildSettings.Editor" ; 
517+             return  iconName ; 
585518        } 
586519
587-         /// <summary> 
588-         /// Module display name as defined on native side in "BuildTargetGroupName.h" 
589-         /// </summary> 
590-         static string  GetModuleDisplayName ( string  moduleName ) 
520+         static string  GetModuleDisplayName ( string  platformId ) 
591521        { 
592-             if  ( ! s_DiscoveredTargetInfos . TryGetValue ( moduleName ,  out  var  gt ) ) 
593-                 return  moduleName ; 
594- 
595-             return  BuildPipeline . GetBuildTargetGroupDisplayName ( BuildPipeline . GetBuildTargetGroup ( gt . buildTargetPlatformVal ) ) ; 
522+             return  BuildTargetDiscovery . BuildPlatformDisplayName ( new  GUID ( platformId ) ) ; 
596523        } 
597524
598525        /// <summary> 
0 commit comments