@@ -117,16 +117,16 @@ class UnityProjectInstance {
117
117
118
118
UnityProjectInstance([string ]$path ) {
119
119
$versionFile = [io.path ]::Combine($path , " ProjectSettings\ProjectVersion.txt" )
120
- if (! (Test-Path $versionFile )) { throw " Path is not a Unity project: $path " }
120
+ if (! (Test-Path $versionFile )) { throw " Path is not a Unity project: $path " }
121
121
122
122
$fileVersion = (Get-Content $versionFile - Raw | ConvertFrom-Yaml )[' m_EditorVersion' ];
123
- if (! $fileVersion ) { throw " Project is missing a version in: $versionFile " }
123
+ if (! $fileVersion ) { throw " Project is missing a version in: $versionFile " }
124
124
125
125
$projectSettingsFile = [io.path ]::Combine($path , " ProjectSettings\ProjectSettings.asset" )
126
- if (! (Test-Path $projectSettingsFile )) { throw " Project is missing ProjectSettings.asset" }
126
+ if (! (Test-Path $projectSettingsFile )) { throw " Project is missing ProjectSettings.asset" }
127
127
128
128
$prodName = ((Get-Content $projectSettingsFile - Raw | ConvertFrom-Yaml )[' playerSettings' ])[' productName' ]
129
- if (! $prodName ) { throw " ProjectSettings is missing productName" }
129
+ if (! $prodName ) { throw " ProjectSettings is missing productName" }
130
130
131
131
$this.Path = $path
132
132
$this.Version = $fileVersion
@@ -144,7 +144,7 @@ class UnityVersion : System.IComparable {
144
144
145
145
[string ] ToString() {
146
146
$result = " $ ( $this.Major ) .$ ( $this.Minor ) .$ ( $this.Revision ) $ ( $this.Release ) $ ( $this.Build ) "
147
- if ( $this.Suffix ) { $result += " -$ ( $this.Suffix ) " }
147
+ if ( $this.Suffix ) { $result += " -$ ( $this.Suffix ) " }
148
148
return $result
149
149
}
150
150
@@ -166,7 +166,7 @@ class UnityVersion : System.IComparable {
166
166
167
167
[int ] CompareTo([object ]$obj ) {
168
168
if ($null -eq $obj ) { return 1 }
169
- if ($obj -isnot [UnityVersion ]) { throw " Object is not a UnityVersion" }
169
+ if ($obj -isnot [UnityVersion ]) { throw " Object is not a UnityVersion" }
170
170
171
171
return [UnityVersion ]::Compare($this , $obj )
172
172
}
@@ -245,7 +245,7 @@ function Get-OperatingSystem {
245
245
function Get-UnityEditor {
246
246
[CmdletBinding ()]
247
247
param (
248
- [ValidateScript ( {Test-Path $_ - PathType Container} )]
248
+ [ValidateScript ( { Test-Path $_ - PathType Container } )]
249
249
[Parameter (Mandatory = $false , ValueFromPipeline = $true , Position = 0 , ParameterSetName = " Path" )]
250
250
[string []]$Path = $PWD ,
251
251
@@ -426,27 +426,30 @@ function Find-UnitySetupInstaller {
426
426
$searchPages += $patchPage
427
427
428
428
$webResult = Invoke-WebRequest $patchPage - UseBasicParsing
429
- $searchPages += $webResult.Links | Where-Object {
430
- $_.href -match " \/unity\/qa\/patch-releases\?version=$ ( $Version.Major ) \.$ ( $Version.Minor ) &page=(\d+)" -and $Matches [1 ] -gt 1
431
- } | ForEach-Object { " https://unity3d.com$ ( $_.href ) " }
429
+ $searchPages += $webResult.Links |
430
+ Where-Object { $_.href -match " \/unity\/qa\/patch-releases\?version=$ ( $Version.Major ) \.$ ( $Version.Minor ) &page=(\d+)" -and $Matches [1 ] -gt 1 } |
431
+ ForEach-Object { " https://unity3d.com$ ( $_.href ) " }
432
432
}
433
433
}
434
434
435
435
foreach ($page in $searchPages ) {
436
436
try {
437
437
$webResult = Invoke-WebRequest $page - UseBasicParsing
438
- $prototypeLink = $webResult.Links | Select-Object - ExpandProperty href - ErrorAction SilentlyContinue | Where-Object {
439
- $link = $_
440
-
441
- foreach ( $installer in $installerTemplates.Keys ) {
442
- foreach ( $template in $installerTemplates [$installer ] ) {
443
- if ( $link -like " *$template *" ) { return $true }
438
+ $prototypeLink = $webResult.Links |
439
+ Select-Object - ExpandProperty href - ErrorAction SilentlyContinue |
440
+ Where-Object {
441
+ $link = $_
442
+
443
+ foreach ( $installer in $installerTemplates.Keys ) {
444
+ foreach ( $template in $installerTemplates [$installer ] ) {
445
+ if ( $link -like " *$template *" ) { return $true }
446
+ }
444
447
}
445
- }
446
448
447
- return $false
449
+ return $false
448
450
449
- } | Select-Object - First 1
451
+ } |
452
+ Select-Object - First 1
450
453
451
454
if ($null -ne $prototypeLink ) { break }
452
455
}
@@ -465,10 +468,10 @@ function Find-UnitySetupInstaller {
465
468
$knownBaseUrls = $linkComponents [0 ], $knownBaseUrls
466
469
}
467
470
else {
468
- $knownBaseUrls = $knownBaseUrls | Sort-Object - Property @ { Expression = {[math ]::Abs(($_.CompareTo ($linkComponents [0 ])))}; Ascending = $true }
471
+ $knownBaseUrls = $knownBaseUrls | Sort-Object - Property @ { Expression = { [math ]::Abs(($_.CompareTo ($linkComponents [0 ]))) }; Ascending = $true }
469
472
}
470
473
471
- $installerTemplates.Keys | Where-Object { $Components -band $_ } | ForEach-Object {
474
+ $installerTemplates.Keys | Where-Object { $Components -band $_ } | ForEach-Object {
472
475
$templates = $installerTemplates.Item ($_ );
473
476
$result = $null
474
477
foreach ($template in $templates ) {
@@ -679,7 +682,7 @@ function Request-UnitySetupInstaller {
679
682
$downloads = @ ()
680
683
681
684
try {
682
- $global :downloadData = [ordered ]@ {}
685
+ $global :downloadData = [ordered ]@ { }
683
686
$downloadIndex = 1
684
687
685
688
$allInstallers | ForEach-Object {
@@ -934,7 +937,7 @@ function Install-UnitySetupInstance {
934
937
$defaultInstallPath = $BasePath
935
938
}
936
939
937
- $versionInstallers = @ {}
940
+ $versionInstallers = @ { }
938
941
}
939
942
process {
940
943
# Sort each installer received from the pipe into versions
@@ -1170,7 +1173,7 @@ function Get-UnitySetupInstanceVersion {
1170
1173
[CmdletBinding ()]
1171
1174
param (
1172
1175
[ValidateNotNullOrEmpty ()]
1173
- [ValidateScript ( {Test-Path $_ - PathType Container})]
1176
+ [ValidateScript ( { Test-Path $_ - PathType Container })]
1174
1177
[Parameter (Mandatory = $true , Position = 0 )]
1175
1178
[string ]$Path
1176
1179
)
@@ -1322,11 +1325,11 @@ function Get-UnityProjectInstance {
1322
1325
1323
1326
Get-ChildItem @args |
1324
1327
ForEach-Object {
1325
- $path = [io.path ]::Combine($_.FullName , " ProjectVersion.txt" )
1326
- if ( Test-Path $path ) {
1327
- [UnityProjectInstance ]::new((Join-Path $_.FullName " ..\" | Convert-Path ))
1328
+ $path = [io.path ]::Combine($_.FullName , " ProjectVersion.txt" )
1329
+ if ( Test-Path $path ) {
1330
+ [UnityProjectInstance ]::new((Join-Path $_.FullName " ..\" | Convert-Path ))
1331
+ }
1328
1332
}
1329
- }
1330
1333
}
1331
1334
1332
1335
<#
@@ -1607,8 +1610,8 @@ function Start-UnityEditor {
1607
1610
if ( $instanceArgs [$i ] ) { $unityArgs += $instanceArgs [$i ] }
1608
1611
1609
1612
$actionString = " $editor $unityArgs "
1610
- if ( $Credential ) { $actionString += " -password (hidden)" }
1611
- if ( $Serial ) { $actionString += " -serial (hidden)" }
1613
+ if ( $Credential ) { $actionString += " -password (hidden)" }
1614
+ if ( $Serial ) { $actionString += " -serial (hidden)" }
1612
1615
1613
1616
if (-not $PSCmdlet.ShouldProcess ($actionString , " System.Diagnostics.Process.Start()" )) {
1614
1617
continue
0 commit comments