@@ -225,6 +225,8 @@ function Select-UnitySetupInstance
225
225
Should the Unity Editor quit after it's done?
226
226
. PARAMETER Wait
227
227
Should the command wait for the Unity Editor to exit?
228
+ . PARAMETER PassThru
229
+ Should the command return the process object? Default is nothing.
228
230
. EXAMPLE
229
231
Start-UnityEditor
230
232
. EXAMPLE
@@ -251,7 +253,9 @@ function Start-UnityEditor
251
253
[parameter (Mandatory = $false )]
252
254
[switch ] $Quit ,
253
255
[parameter (Mandatory = $false )]
254
- [switch ] $Wait
256
+ [switch ] $Wait ,
257
+ [parameter (Mandatory = $false )]
258
+ [switch ] $PassThru
255
259
)
256
260
257
261
if ( $Instance -eq $null )
@@ -276,43 +280,13 @@ function Start-UnityEditor
276
280
277
281
$editor = Get-ChildItem " $unityPath " - Filter Unity.exe - Recurse | Select-Object - First 1 - ExpandProperty FullName
278
282
279
- $args = @ ()
280
- $args += " -projectPath"
281
- $args += $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath ($Project )
282
-
283
- if ( $ExecuteMethod )
284
- {
285
- $args += " -executeMethod"
286
- $args += $ExecuteMethod
287
- }
288
-
289
- if ( $OutputPath )
290
- {
291
- $args += " -buildOutput"
292
- $args += $OutputPath
293
- }
294
-
295
- if ( $LogFile )
296
- {
297
- $args += " -logFile"
298
- $args += $LogFile
299
- }
300
-
301
- if ( $BuildTarget )
302
- {
303
- $args += " -buildTarget"
304
- $args += $BuildTarget
305
- }
306
-
307
- if ( $BatchMode )
308
- {
309
- $args += " -batchmode"
310
- }
311
-
312
- if ( $Quit )
313
- {
314
- $args += " -quit"
315
- }
283
+ $args = " -projectPath" , $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath ($Project )
284
+ if ( $ExecuteMethod ) { $args += " -executeMethod" , $ExecuteMethod }
285
+ if ( $OutputPath ) { $args += " -buildOutput" , $OutputPath }
286
+ if ( $LogFile ) { $args += " -logFile" , $LogFile }
287
+ if ( $BuildTarget ) { $args += " -buildTarget" , $BuildTarget }
288
+ if ( $BatchMode ) { $args += " -batchmode" }
289
+ if ( $Quit ) { $args += " -quit" }
316
290
317
291
Write-Host " $editor $args " - ForegroundColor Green
318
292
$process = Start-Process - FilePath $editor - ArgumentList $args - PassThru - ErrorAction Stop
@@ -330,4 +304,6 @@ function Start-UnityEditor
330
304
throw " Unity quit with non-zero exit code"
331
305
}
332
306
}
307
+
308
+ if ( $PassThru ) { $process }
333
309
}
0 commit comments