@@ -25,7 +25,6 @@ public class WindowsPlatform : IInstallerPlatform
2525 /// <summary>
2626 /// Paths where Unity installations are searched in.
2727 /// </summary>
28- /// <value></value>
2928 static readonly string [ ] INSTALL_LOCATIONS = new string [ ] {
3029 ProgramFilesPath ,
3130 Path . Combine ( ProgramFilesPath , "Unity" , "Editor" ) ,
@@ -53,6 +52,11 @@ string GetLocalApplicationDataDirectory()
5352 UnityInstaller . PRODUCT_NAME ) ;
5453 }
5554
55+ public void SetConfiguration ( Configuration configuration )
56+ {
57+ this . configuration = configuration ;
58+ }
59+
5660 public Task < CachePlatform > GetCurrentPlatform ( )
5761 {
5862 return Task . FromResult ( CachePlatform . Windows ) ;
@@ -115,12 +119,23 @@ public Task<Installation> CompleteInstall(bool aborted, CancellationToken cancel
115119
116120 public async Task < IEnumerable < Installation > > FindInstallations ( CancellationToken cancellation = default )
117121 {
122+ var locations = INSTALL_LOCATIONS ;
123+ if ( configuration != null && ! string . IsNullOrEmpty ( configuration . searchPathWindows ) ) {
124+ locations = configuration . searchPathWindows . Split ( ';' , StringSplitOptions . RemoveEmptyEntries ) ;
125+ var comparison = StringComparison . OrdinalIgnoreCase ;
126+ for ( int i = 0 ; i < locations . Length ; i ++ ) {
127+ locations [ i ] = Helpers . Replace ( locations [ i ] , "{ProgramFiles}" , ProgramFilesPath , comparison ) ;
128+ }
129+ }
130+
118131 var unityInstallations = new List < Installation > ( ) ;
119- foreach ( var installPath in INSTALL_LOCATIONS )
132+ foreach ( var installPath in locations )
120133 {
121134 if ( ! Directory . Exists ( installPath ) )
122135 continue ;
123136
137+ Logger . LogDebug ( $ "Searching directory for Unity installations: { installPath } ") ;
138+
124139 foreach ( var unityCandidate in Directory . EnumerateDirectories ( installPath ) )
125140 {
126141 var unityExePath = Path . Combine ( unityCandidate , "Editor" , "Unity.exe" ) ;
@@ -133,7 +148,8 @@ public async Task<IEnumerable<Installation>> FindInstallations(CancellationToken
133148 var versionInfo = FileVersionInfo . GetVersionInfo ( unityExePath ) ;
134149 var splitCharacter = versionInfo . ProductVersion . Contains ( "_" ) ? '_' : '.' ; // Versions are on format 2020.3.34f1_xxxx or 2020.3.34f1.xxxx
135150
136- Logger . LogDebug ( $ "Found version { versionInfo . ProductVersion } ") ;
151+ Logger . LogDebug ( $ "Found version { versionInfo . ProductVersion } at path: { unityCandidate } ") ;
152+
137153 unityInstallations . Add ( new Installation {
138154 executable = unityExePath ,
139155 path = unityCandidate ,
@@ -260,6 +276,8 @@ public async Task Uninstall(Installation installation, CancellationToken cancell
260276
261277 ILogger Logger = UnityInstaller . CreateLogger < WindowsPlatform > ( ) ;
262278
279+ Configuration configuration ;
280+
263281 VersionMetadata installing ;
264282 string installationPaths ;
265283 bool installedEditor ;
@@ -294,7 +312,7 @@ string GetInstallationPath(UnityVersion version, string installationPaths)
294312 if ( ! string . IsNullOrEmpty ( installationPaths ) )
295313 {
296314 var comparison = StringComparison . OrdinalIgnoreCase ;
297- var paths = installationPaths . Split ( new char [ ] { ';' } , StringSplitOptions . RemoveEmptyEntries ) ;
315+ var paths = installationPaths . Split ( ';' , StringSplitOptions . RemoveEmptyEntries ) ;
298316 foreach ( var path in paths )
299317 {
300318 expanded = path . Trim ( ) ;
0 commit comments