Yeah the unitysetup.powershell does a recursive search but it can be slow.
I was looking at adding hub support to it. Here’s what I have so far:
$version = "m_EditorVersionWithRevision: 2019.1.14f1 (148b5891095a)"
$pattern = '(?<version>(?:(?<major>\d+)\.)?(?:(?<minor>\d+)\.)?(?:(?<patch>\d+[fab]\d+)\b))|((?:\((?<revision>\w+))\))'
$versonMatches = [regex]::Matches($version, $pattern)
$UnityVersion = $versonMatches[0].Groups['version'].Value.Trim()
$UnityVersionChangeSet = $versonMatches[1].Groups['revision'].Value.Trim()
if ( (-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT") ) {
$hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe"
$editorRootPath = "C:\Program Files\Unity\Hub\Editor\"
$editorFileEx = "\Editor\Unity.exe"
$modules = @('windows-il2cpp', 'universal-windows-platform', 'lumin', 'webgl', 'android')
#"Unity Hub.exe" -- --headless help
#. 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless help
function unity-hub {
$p = Start-Process -Verbose -NoNewWindow -PassThru -Wait -FilePath "$hubPath" -ArgumentList (@('--','--headless') + $args.Split(" "))
}
}
elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) {
$hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"
This file has been truncated. show original
Should work for mac and windows, but there’s still problems with the linux hub installer, and I haven’t been able to figure out how to properly install it in powershell.
Hope this helps
Cheers,
1 Like