Skip to content

Commit 3b6b002

Browse files
committed
- Resolves issue with finding Unity 2018.3 or higher for macOS.
- Resolves issues if recursive directories do not exist in install path for macOS.
1 parent 38e1883 commit 3b6b002

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,24 @@ function Find-UnitySetupInstaller {
374374
}
375375

376376
if ($null -eq $prototypeLink) {
377-
throw "Could not find archives for Unity version $Version"
377+
# Attempt to find Unity version and setup links based off builtin_shaders download.
378+
Write-Verbose "Attempting version search with builtin_shaders fallback"
379+
foreach ($page in $searchPages) {
380+
$webResult = Invoke-WebRequest $page -UseBasicParsing
381+
$prototypeLink = $webResult.Links | Select-Object -ExpandProperty href -ErrorAction SilentlyContinue | Where-Object {
382+
$_ -match "builtin_shaders-$($Version).zip$"
383+
}
384+
385+
if ($null -ne $prototypeLink) { break }
386+
}
387+
388+
if ($null -eq $prototypeLink) {
389+
throw "Could not find archives for Unity version $Version"
390+
}
391+
else {
392+
# Regex needs to be reconfigured to parse builtin_shaders's url link
393+
$unitySetupRegEx = "^(.+)\/([a-z0-9]+)\/builtin_shaders-(\d+)\.(\d+)\.(\d+)([fpb])(\d+).zip$"
394+
}
378395
}
379396

380397
$linkComponents = $prototypeLink -split $unitySetupRegEx -ne ""
@@ -959,11 +976,18 @@ function Install-UnitySetupInstance {
959976

960977
# Move the install from the sparse bundle disk to the install directory.
961978
if ($currentOS -eq [OperatingSystem]::Mac) {
979+
# rsync does not recursively create the directory path.
980+
if (-not (Test-Path $installPath -PathType Container))
981+
{
982+
Write-Verbose "Creating directory $installPath."
983+
New-Item $installPath -ItemType Directory -ErrorAction Stop | Out-Null
984+
}
985+
962986
Write-Verbose "Copying install to $installPath."
963987
# Copy the files (-r) and recreate symlinks (-l) to the install directory.
964988
# Preserve permissions (-p) and owner (-o).
965989
# chmod gives files read permissions.
966-
& sudo rsync -rlpo $volumeInstallPath $installPath --chmod=+r --remove-source-files
990+
& sudo rsync -rlpo $volumeInstallPath $installPath --chmod="+wr" --remove-source-files
967991

968992
Write-Verbose "Freeing sparse bundle disk space and unmounting."
969993
# Ensure the drive is cleaned up.

0 commit comments

Comments
 (0)