@@ -17,7 +17,7 @@ if ([String]::IsNullOrEmpty($unityVersion)) {
17
17
}
18
18
19
19
$projectPath = (Get-Item $versionFilePath ).Directory.Parent.FullName
20
- $projectPath = $projectPath -replace ' \\' , ' /'
20
+ $projectPath = $projectPath -replace ' \\' , ' /'
21
21
Write-Host " Unity project path: `" $projectPath `" "
22
22
" UNITY_PROJECT_PATH=$projectPath " >> $env: GITHUB_ENV
23
23
}
@@ -27,7 +27,8 @@ if ([String]::IsNullOrEmpty($unityVersion)) {
27
27
$vMatches = [regex ]::Matches($version , $pattern )
28
28
$unityVersion = $vMatches [1 ].Groups[' version' ].Value.Trim()
29
29
$unityVersionChangeSet = $vMatches [2 ].Groups[' revision' ].Value.Trim()
30
- } else {
30
+ }
31
+ else {
31
32
$version = $unityVersion
32
33
$unityVersionChangeSet = $version -replace ' .*\((.*)\)' , ' $1'
33
34
$unityVersion = $version -replace ' \s*\(.*\)' , ' '
@@ -37,7 +38,8 @@ if (-not ([String]::IsNullOrEmpty($unityVersion))) {
37
38
Write-Host " "
38
39
" UNITY_EDITOR_VERSION=$unityVersion " >> $env: GITHUB_ENV
39
40
Write-Host " Unity Editor version set to: $unityVersion "
40
- } else {
41
+ }
42
+ else {
41
43
Write-Error " Failed to determine editor version to install!"
42
44
exit 1
43
45
}
@@ -53,11 +55,12 @@ if ($IsWindows) {
53
55
54
56
# . 'C:/Program Files/Unity Hub/Unity Hub.exe' -- --headless help
55
57
function Invoke-UnityHub {
56
- $argList = (@ (' --' , ' --headless' ) + $args.Split (" " ))
58
+ $argList = (@ (' --' , ' --headless' ) + $args.Split (" " ))
57
59
$p = Start-Process - NoNewWindow - PassThru - Wait - FilePath " $hubPath " - ArgumentList $argList
58
60
$p.WaitForExit ()
59
61
}
60
- } elseif ($IsMacOS ) {
62
+ }
63
+ elseif ($IsMacOS ) {
61
64
$hubPath = " /Applications/Unity Hub.app/Contents/MacOS/Unity Hub"
62
65
$editorRootPath = " /Applications/Unity/Hub/Editor/"
63
66
$editorFileEx = " /Unity.app/Contents/MacOS/Unity"
@@ -68,11 +71,12 @@ if ($IsWindows) {
68
71
69
72
# . "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" -- --headless help
70
73
function Invoke-UnityHub {
71
- $argList = (@ (' --' , ' --headless' ) + $args.Split (" " ))
74
+ $argList = (@ (' --' , ' --headless' ) + $args.Split (" " ))
72
75
$p = Start-Process - NoNewWindow - PassThru - Wait - FilePath " $hubPath " - ArgumentList $argList
73
76
$p.WaitForExit ()
74
77
}
75
- } elseif ($IsLinux ) {
78
+ }
79
+ elseif ($IsLinux ) {
76
80
$hubPath = " /usr/bin/unityhub"
77
81
$editorRootPath = " $HOME /Unity/Hub/Editor/"
78
82
$editorFileEx = " /Editor/Unity"
@@ -86,7 +90,8 @@ if ($IsWindows) {
86
90
$argsList = $args.Split (" " )
87
91
xvfb- run -- auto- servernum " $hubPath " -- disable-gpu - sandbox -- headless $argsList
88
92
}
89
- } else {
93
+ }
94
+ else {
90
95
Write-Error " Unsupported platform: $ ( $global :PSVersionTable.Platform ) "
91
96
exit 1
92
97
}
@@ -115,7 +120,8 @@ if ( -not (Test-Path -Path "$hubPath") ) {
115
120
Write-Error " $ ( Get-Date ) : Failed with exit code: $ ( $process.ExitCode ) "
116
121
exit 1
117
122
}
118
- } elseif ($IsMacOS ) {
123
+ }
124
+ elseif ($IsMacOS ) {
119
125
Write-Host " ::group::Installing Unity Hub on macOS..."
120
126
$package = " UnityHubSetup.dmg"
121
127
$downloadPath = " $outPath /$package "
@@ -146,17 +152,28 @@ if ( -not (Test-Path -Path "$hubPath") ) {
146
152
147
153
sudo cp - rf $dmgAppPath " /Applications"
148
154
hdiutil unmount $dmgVolume
155
+
156
+ if (! (Test-Path $hubPath )) {
157
+ Write-Error " Failed to install Unity Hub"
158
+ exit 1
159
+ }
160
+
161
+ Write-Host " Unity Hub installed at `" $hubPath `" "
162
+
163
+ sudo chmod - R 777 $hubPath
149
164
sudo mkdir - p " /Library/Application Support/Unity"
150
- sudo chmod 775 " /Library/Application Support/Unity"
151
- touch ' /Library/Application Support/Unity/temp '
152
- } elseif ($IsLinux ) {
165
+ sudo chmod - R 777 " /Library/Application Support/Unity"
166
+ }
167
+ elseif ($IsLinux ) {
153
168
Write-Host " ::group::Installing Unity Hub on ubuntu..."
154
169
sudo sh - c ' echo ""deb https://hub.unity3d.com/linux/repos/deb stable main"" > /etc/apt/sources.list.d/unityhub.list'
155
170
wget - qO - https:// hub.unity3d.com / linux/ keys/ public | sudo apt- key add -
156
171
sudo apt update
157
172
sudo apt install - y unityhub
158
173
$hubPath = which unityhub
159
- } else {
174
+ sudo chmod - R 777 $hubPath
175
+ }
176
+ else {
160
177
Write-Error " Unsupported platform: $ ( $global :PSVersionTable.Platform ) "
161
178
exit 1
162
179
}
@@ -181,7 +198,7 @@ Write-Host "::endgroup::"
181
198
# }
182
199
183
200
# set the editor path
184
- $editorPath = " {0}{1}{2}" -f $editorRootPath , $unityVersion , $editorFileEx
201
+ $editorPath = " {0}{1}{2}" -f $editorRootPath , $unityVersion , $editorFileEx
185
202
186
203
# if architecture is set, check if the specific architecture is installed
187
204
if (-not [string ]::IsNullOrEmpty($architecture )) {
@@ -192,12 +209,15 @@ if (-not [string]::IsNullOrEmpty($architecture)) {
192
209
193
210
# iterate over the editors and check if the version name contains (Intel) for x86_64 or (Apple silicon) for arm64
194
211
foreach ($archEditor in $archEditors ) {
212
+ Write-Host " ::debug::$archEditor "
213
+
195
214
if ($IsMacOS ) {
196
215
if ((($archEditor.Contains (" (Intel)" ) -and $architecture -eq ' x86_64' )) -or ($archEditor.Contains (" (Apple silicon)" ) -and $architecture -eq ' arm64' )) {
197
216
# set the editor path based on the editor string that was found using a substring. Split subtring by ',' and take the last element
198
217
$editorPath = $archEditor.Substring (0 , $archEditor.IndexOf (' ,' ))
199
218
}
200
- } else {
219
+ }
220
+ else {
201
221
Write-Error " Architecture lookup not supported for $ ( $global :PSVersionTable.Platform ) "
202
222
exit 1
203
223
}
@@ -242,17 +262,18 @@ function AddModules {
242
262
243
263
if (-not (Test-Path - Path $editorPath )) {
244
264
Write-Host " Installing $unityVersion ($unityVersionChangeSet )"
245
- $installArgs = @ (' install' , " --version $unityVersion " , " --changeset $unityVersionChangeSet " , ' --cm' )
265
+ $installArgs = @ (' install' , " --version $unityVersion " , " --changeset $unityVersionChangeSet " , ' --cm' )
246
266
$installModules = AddModules
247
267
248
268
if (-not [string ]::IsNullOrEmpty($architecture )) {
249
269
$installArgs += " -a $architecture "
250
270
}
251
271
252
272
Invoke-Hub - Install $installModules $installArgs
253
- } else {
273
+ }
274
+ else {
254
275
Write-Host " Checking modules for $unityVersion ($unityVersionChangeSet )"
255
- $installArgs = @ (' install-modules' , " --version $unityVersion " , ' --cm' )
276
+ $installArgs = @ (' install-modules' , " --version $unityVersion " , ' --cm' )
256
277
$installModules = AddModules
257
278
258
279
if ($installModules.Count -gt 0 ) {
@@ -264,14 +285,14 @@ Write-Host "Installed Editors:"
264
285
Invoke-UnityHub editors - i
265
286
266
287
if (-not (Test-Path - Path $editorPath )) {
267
- Write-Error " Failed to validate installed editor path at $editorPath "
288
+ Write-Error " Failed to validate installed editor path at `" $editorPath `" "
268
289
exit 1
269
290
}
270
291
271
- $modulesPath = ' {0}{1}/modules.json' -f $editorRootPath , $UnityVersion
292
+ $modulesPath = ' {0}{1}/modules.json' -f $editorRootPath , $UnityVersion
272
293
273
294
if (-not (Test-Path - Path $modulesPath )) {
274
- $editorPath = " {0}{1}" -f $editorRootPath , $unityVersion
295
+ $editorPath = " {0}{1}" -f $editorRootPath , $unityVersion
275
296
Write-Error " Failed to resolve modules path at $modulesPath "
276
297
277
298
if (Test-Path - Path $editorPath ) {
@@ -295,9 +316,9 @@ $envEditorPath = $env:UNITY_EDITOR_PATH
295
316
296
317
if ([String ]::IsNullOrEmpty($envEditorPath )) {
297
318
Write-Host " "
298
- $editorPath = $editorPath -replace ' \\' , ' /'
319
+ $editorPath = $editorPath -replace ' \\' , ' /'
299
320
" UNITY_EDITOR_PATH=$editorPath " >> $env: GITHUB_ENV
300
- Write-Host " UnityEditor path set to: $editorPath "
321
+ Write-Host " UnityEditor path set to: `" $editorPath `" "
301
322
}
302
323
303
324
exit 0
0 commit comments