Skip to content

Commit 51d8d94

Browse files
finalized matching in modules
1 parent 64ac797 commit 51d8d94

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,20 @@ class UnitySetupInstance {
5252
$currentOS = Get-OperatingSystem
5353
$foundVersion = $false
5454

55+
Write-Verbose "Attempting to get Unity Setup Instance at $path"
56+
5557
if ( Test-Path "$path\modules.json" ) {
58+
5659
$modules = (Get-Content "$path\modules.json" -Raw) | ConvertFrom-Json
5760

5861
foreach ( $module in $modules ) {
59-
$match = $module.DownloadUrl -match "(\d+)\.(\d+)\.(\d+)([fpab])(\d+)" | Out-Null
62+
Write-Verbose "Found module $($module.id)"
63+
Write-Verbose "Download Url $($module.DownloadUrl)"
6064

61-
if ( $null -ne $match ) {
62-
$this.Version = [UnityVersion]$match
65+
if ( $module.DownloadUrl -match "(\d+)\.(\d+)\.(\d+)([fpab])(\d+)" ) {
66+
$this.Version = [UnityVersion]$Matches[0]
6367
$foundVersion = $true
68+
Write-Verbose "Found $($this.Version)"
6469
break
6570
}
6671
}
@@ -1108,8 +1113,9 @@ function Get-UnitySetupInstance {
11081113
$setupInstances = [UnitySetupInstance[]]@()
11091114

11101115
foreach ( $path in $searchPaths ) {
1111-
if( $path -like '*Unity Hub*' ) { continue }
1112-
$setupInstances += , [UnitySetupInstance]::new($path)
1116+
if( $path -match "(\d+)\.(\d+)\.(\d+)([fpab])(\d+)") {
1117+
$setupInstances += , [UnitySetupInstance]::new($path)
1118+
}
11131119
}
11141120

11151121
return $setupInstances

0 commit comments

Comments
 (0)