Skip to content

Commit a7f9f6d

Browse files
committed
Better support for UnitySetupComponent
1 parent a276a98 commit a7f9f6d

File tree

2 files changed

+54
-34
lines changed

2 files changed

+54
-34
lines changed

UnitySetup/UnitySetup.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ FunctionsToExport = @(
8181
'Install-UnitySetupInstance',
8282
'Select-UnitySetupInstance',
8383
'Uninstall-UnitySetupInstance',
84-
'Start-UnityEditor'
84+
'Start-UnityEditor',
85+
'New-UnitySetupComponent'
8586
)
8687

8788
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.

UnitySetup/UnitySetup.psm1

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Import-Module powershell-yaml -Force -ErrorAction Stop
44

55
[Flags()]
6-
enum UnitySetupComponentType
6+
enum UnitySetupComponent
77
{
88
Setup = (1 -shl 0)
99
Documentation = (1 -shl 1)
@@ -24,7 +24,7 @@ enum UnitySetupComponentType
2424

2525
class UnitySetupInstaller
2626
{
27-
[UnitySetupComponentType] $ComponentType
27+
[UnitySetupComponent] $ComponentType
2828
[UnityVersion] $Version
2929
[int64]$Length
3030
[DateTime]$LastModified
@@ -34,7 +34,7 @@ class UnitySetupInstaller
3434
class UnitySetupInstance
3535
{
3636
[UnityVersion]$Version
37-
[UnitySetupComponentType]$Components
37+
[UnitySetupComponent]$Components
3838
[string]$Path
3939

4040
UnitySetupInstance([string]$path) {
@@ -49,23 +49,23 @@ class UnitySetupInstance
4949

5050
$this.Path = $path
5151
$this.Version = $xmlDoc.'ivy-module'.info.unityVersion
52-
$this.Components = [UnitySetupComponentType]::Setup
52+
$this.Components = [UnitySetupComponent]::Setup
5353

5454
$componentTests = @{
55-
[UnitySetupComponentType]::Documentation = ,"$Path\Editor\Data\Documentation";
56-
[UnitySetupComponentType]::StandardAssets = ,"$Path\Editor\Standard Assets";
57-
[UnitySetupComponentType]::Windows_IL2CPP = ,"$Path\Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win32_development_il2cpp";
58-
[UnitySetupComponentType]::Metro = "$Path\Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_.NET_D3D",
55+
[UnitySetupComponent]::Documentation = ,"$Path\Editor\Data\Documentation";
56+
[UnitySetupComponent]::StandardAssets = ,"$Path\Editor\Standard Assets";
57+
[UnitySetupComponent]::Windows_IL2CPP = ,"$Path\Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win32_development_il2cpp";
58+
[UnitySetupComponent]::Metro = "$Path\Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_.NET_D3D",
5959
"$Path\Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_D3D";
60-
[UnitySetupComponentType]::UWP_IL2CPP = ,"$Path\Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_IL2CPP_D3D";
61-
[UnitySetupComponentType]::Android = ,"$Path\Editor\Data\PlaybackEngines\AndroidPlayer";
62-
[UnitySetupComponentType]::iOS = , "$Path\Editor\Data\PlaybackEngines\iOSSupport";
63-
[UnitySetupComponentType]::AppleTV = , "$Path\Editor\Data\PlaybackEngines\AppleTVSupport";
64-
[UnitySetupComponentType]::Facebook = , "$Path\Editor\Data\PlaybackEngines\Facebook";
65-
[UnitySetupComponentType]::Linux = , "$Path\Editor\Data\PlaybackEngines\LinuxStandaloneSupport";
66-
[UnitySetupComponentType]::Mac = , "$Path\Editor\Data\PlaybackEngines\MacStandaloneSupport";
67-
[UnitySetupComponentType]::Vuforia = , "$Path\Editor\Data\PlaybackEngines\VuforiaSupport";
68-
[UnitySetupComponentType]::WebGL = , "$Path\Editor\Data\PlaybackEngines\WebGLSupport";
60+
[UnitySetupComponent]::UWP_IL2CPP = ,"$Path\Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_IL2CPP_D3D";
61+
[UnitySetupComponent]::Android = ,"$Path\Editor\Data\PlaybackEngines\AndroidPlayer";
62+
[UnitySetupComponent]::iOS = , "$Path\Editor\Data\PlaybackEngines\iOSSupport";
63+
[UnitySetupComponent]::AppleTV = , "$Path\Editor\Data\PlaybackEngines\AppleTVSupport";
64+
[UnitySetupComponent]::Facebook = , "$Path\Editor\Data\PlaybackEngines\Facebook";
65+
[UnitySetupComponent]::Linux = , "$Path\Editor\Data\PlaybackEngines\LinuxStandaloneSupport";
66+
[UnitySetupComponent]::Mac = , "$Path\Editor\Data\PlaybackEngines\MacStandaloneSupport";
67+
[UnitySetupComponent]::Vuforia = , "$Path\Editor\Data\PlaybackEngines\VuforiaSupport";
68+
[UnitySetupComponent]::WebGL = , "$Path\Editor\Data\PlaybackEngines\WebGLSupport";
6969
}
7070

7171
$componentTests.Keys | ForEach-Object {
@@ -159,6 +159,25 @@ class UnityVersion : System.IComparable
159159
}
160160
}
161161

162+
<#
163+
.Synopsis
164+
Help to create UnitySetupComponent
165+
.PARAMETER Components
166+
What components would you like included?
167+
.EXAMPLE
168+
New-UnitySetupComponent -Components Setup,Metro
169+
#>
170+
function New-UnitySetupComponent
171+
{
172+
[CmdletBinding()]
173+
param(
174+
[parameter(Mandatory=$true)]
175+
[UnitySetupComponent] $Components
176+
)
177+
178+
$Components
179+
}
180+
162181
<#
163182
.Synopsis
164183
Finds UnitySetup installers for a specified version.
@@ -181,7 +200,7 @@ function Find-UnitySetupInstaller
181200
[UnityVersion] $Version,
182201

183202
[parameter(Mandatory=$false)]
184-
[UnitySetupComponentType] $Components = [UnitySetupComponentType]::All
203+
[UnitySetupComponent] $Components = [UnitySetupComponent]::All
185204
)
186205

187206
$unitySetupRegEx = "^(.+)\/([a-z0-9]+)\/Windows64EditorInstaller\/UnitySetup64-(\d+)\.(\d+)\.(\d+)([fpb])(\d+).exe$"
@@ -192,21 +211,21 @@ function Find-UnitySetupInstaller
192211
)
193212

194213
$installerTemplates = @{
195-
[UnitySetupComponentType]::Setup = ,"Windows64EditorInstaller/UnitySetup64-$Version.exe";
196-
[UnitySetupComponentType]::Documentation = ,"WindowsDocumentationInstaller/UnityDocumentationSetup-$Version.exe";
197-
[UnitySetupComponentType]::StandardAssets = ,"WindowsStandardAssetsInstaller/UnityStandardAssetsSetup-$Version.exe";
198-
[UnitySetupComponentType]::Metro = ,"TargetSupportInstaller/UnitySetup-Metro-Support-for-Editor-$Version.exe";
199-
[UnitySetupComponentType]::UWP_IL2CPP = ,"TargetSupportInstaller/UnitySetup-UWP-IL2CPP-Support-for-Editor-$Version.exe";
200-
[UnitySetupComponentType]::Android = ,"TargetSupportInstaller/UnitySetup-Android-Support-for-Editor-$Version.exe";
201-
[UnitySetupComponentType]::iOS = ,"TargetSupportInstaller/UnitySetup-iOS-Support-for-Editor-$Version.exe";
202-
[UnitySetupComponentType]::AppleTV = ,"TargetSupportInstaller/UnitySetup-AppleTV-Support-for-Editor-$Version.exe";
203-
[UnitySetupComponentType]::Facebook = ,"TargetSupportInstaller/UnitySetup-Facebook-Games-Support-for-Editor-$Version.exe";
204-
[UnitySetupComponentType]::Linux = ,"TargetSupportInstaller/UnitySetup-Linux-Support-for-Editor-$Version.exe";
205-
[UnitySetupComponentType]::Mac = "TargetSupportInstaller/UnitySetup-Mac-Support-for-Editor-$Version.exe",
214+
[UnitySetupComponent]::Setup = ,"Windows64EditorInstaller/UnitySetup64-$Version.exe";
215+
[UnitySetupComponent]::Documentation = ,"WindowsDocumentationInstaller/UnityDocumentationSetup-$Version.exe";
216+
[UnitySetupComponent]::StandardAssets = ,"WindowsStandardAssetsInstaller/UnityStandardAssetsSetup-$Version.exe";
217+
[UnitySetupComponent]::Metro = ,"TargetSupportInstaller/UnitySetup-Metro-Support-for-Editor-$Version.exe";
218+
[UnitySetupComponent]::UWP_IL2CPP = ,"TargetSupportInstaller/UnitySetup-UWP-IL2CPP-Support-for-Editor-$Version.exe";
219+
[UnitySetupComponent]::Android = ,"TargetSupportInstaller/UnitySetup-Android-Support-for-Editor-$Version.exe";
220+
[UnitySetupComponent]::iOS = ,"TargetSupportInstaller/UnitySetup-iOS-Support-for-Editor-$Version.exe";
221+
[UnitySetupComponent]::AppleTV = ,"TargetSupportInstaller/UnitySetup-AppleTV-Support-for-Editor-$Version.exe";
222+
[UnitySetupComponent]::Facebook = ,"TargetSupportInstaller/UnitySetup-Facebook-Games-Support-for-Editor-$Version.exe";
223+
[UnitySetupComponent]::Linux = ,"TargetSupportInstaller/UnitySetup-Linux-Support-for-Editor-$Version.exe";
224+
[UnitySetupComponent]::Mac = "TargetSupportInstaller/UnitySetup-Mac-Support-for-Editor-$Version.exe",
206225
"TargetSupportInstaller/UnitySetup-Mac-Mono-Support-for-Editor-$Version.exe";
207-
[UnitySetupComponentType]::Vuforia = ,"TargetSupportInstaller/UnitySetup-Vuforia-AR-Support-for-Editor-$Version.exe";
208-
[UnitySetupComponentType]::WebGL = ,"TargetSupportInstaller/UnitySetup-WebGL-Support-for-Editor-$Version.exe";
209-
[UnitySetupComponentType]::Windows_IL2CPP = ,"TargetSupportInstaller/UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version.exe";
226+
[UnitySetupComponent]::Vuforia = ,"TargetSupportInstaller/UnitySetup-Vuforia-AR-Support-for-Editor-$Version.exe";
227+
[UnitySetupComponent]::WebGL = ,"TargetSupportInstaller/UnitySetup-WebGL-Support-for-Editor-$Version.exe";
228+
[UnitySetupComponent]::Windows_IL2CPP = ,"TargetSupportInstaller/UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version.exe";
210229
}
211230

212231
# By default Tls12 protocol is not enabled, but is what backs Unity's website, so enable it
@@ -240,7 +259,7 @@ function Find-UnitySetupInstaller
240259
{
241260
$webResult = Invoke-WebRequest $page -UseBasicParsing
242261
$prototypeLink = $webResult.Links | Select-Object -ExpandProperty href -ErrorAction SilentlyContinue | Where-Object {
243-
$_ -match "$($installerTemplates[[UnitySetupComponentType]::Setup])$"
262+
$_ -match "$($installerTemplates[[UnitySetupComponent]::Setup])$"
244263
}
245264

246265
if($null -ne $prototypeLink) { break }

0 commit comments

Comments
 (0)