2
2
# Licensed under the MIT License.
3
3
Import-Module powershell- yaml - Force - ErrorAction Stop
4
4
5
+ [Flags ()]
6
+ enum UnitySetupComponentType
7
+ {
8
+ Setup = (1 -shl 0 )
9
+ Documentation = (1 -shl 1 )
10
+ StandardAssets = (1 -shl 2 )
11
+ ExampleProject = (1 -shl 3 )
12
+ Metro = (1 -shl 4 )
13
+ UWP_IL2CPP = (1 -shl 5 )
14
+ Android = (1 -shl 6 )
15
+ iOS = (1 -shl 7 )
16
+ AppleTV = (1 -shl 8 )
17
+ Facebook = (1 -shl 9 )
18
+ Linux = (1 -shl 10 )
19
+ Mac = (1 -shl 11 )
20
+ Vuforia = (1 -shl 12 )
21
+ WebGL = (1 -shl 13 )
22
+ Windows_IL2CPP = (1 -shl 14 )
23
+ All = (-1 )
24
+ }
25
+
5
26
class UnitySetupInstaller
6
27
{
7
28
[UnitySetupComponentType ] $ComponentType
@@ -228,6 +249,7 @@ function Find-UnitySetupInstaller
228
249
function Install-UnitySetupInstance
229
250
{
230
251
[CmdletBinding ()]
252
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute (' PSAvoidUsingWriteHost' , ' ' , Scope= ' Function' )]
231
253
param (
232
254
[parameter (ValueFromPipeline = $true )]
233
255
[UnitySetupInstaller []] $Installers ,
@@ -236,7 +258,11 @@ function Install-UnitySetupInstance
236
258
[string ]$Destination ,
237
259
238
260
[parameter (Mandatory = $false )]
239
- [string ]$Cache = [io.Path ]::Combine($env: USERPROFILE , " .unitysetup" )
261
+ [string ]$Cache = [io.Path ]::Combine($env: USERPROFILE , " .unitysetup" ),
262
+
263
+ [parameter (Mandatory = $false )]
264
+ [ValidateSet (' Open' , ' RunAs' )]
265
+ [string ]$Verb
240
266
)
241
267
242
268
process
@@ -299,10 +325,19 @@ function Install-UnitySetupInstance
299
325
$installer = $localInstallers [$i ]
300
326
$destination = $localDestinations [$i ]
301
327
302
- $args = @ (" /S" , " /D=$ ( $localDestinations [$i ]) " )
328
+ $startProcessArgs = @ {
329
+ ' FilePath' = $installer ;
330
+ ' ArgumentList' = @ (" /S" , " /D=$ ( $localDestinations [$i ]) " );
331
+ ' PassThru' = $true ;
332
+ }
333
+
334
+ if ($Verb )
335
+ {
336
+ $startProcessArgs [' Verb' ] = $Verb
337
+ }
303
338
304
339
$spinnerIndex = 0
305
- $process = Start-Process - FilePath $installer - ArgumentList $args - PassThru
340
+ $process = Start-Process @startProcessArgs
306
341
while (! $process.HasExited )
307
342
{
308
343
Write-Host " `r Installing $installer to $destination - $ ( $spins [$spinnerIndex ++ % $spins.Length ]) " - NoNewline
@@ -496,7 +531,7 @@ function Get-UnityProjectInstance
496
531
#>
497
532
function Start-UnityEditor
498
533
{
499
- [CmdletBinding (DefaultParameterSetName = " Context" )]
534
+ [CmdletBinding (SupportsShouldProcess , DefaultParameterSetName = " Context" )]
500
535
param (
501
536
[parameter (Mandatory = $false , ValueFromPipeline = $true , ParameterSetName = ' Projects' )]
502
537
[parameter (Mandatory = $true , ValueFromPipeline = $true , ParameterSetName = ' ProjectsLatest' )]
@@ -665,7 +700,11 @@ function Start-UnityEditor
665
700
$setProcessArgs [' ArgumentList' ] = $unityArgs
666
701
}
667
702
668
- Write-Verbose " Starting $editor $unityArgs "
703
+ if (-not $PSCmdlet.ShouldProcess (" $editor $unityArgs " , " Start-Process" ))
704
+ {
705
+ continue
706
+ }
707
+
669
708
$process = Start-Process @setProcessArgs
670
709
if ( $Wait )
671
710
{
0 commit comments