Open ForrestTrepte opened 5 years ago
The Hub saves this setting in in c:\users\YOU\AppData\Roaming\UnityHub\secondaryInstallPath.json. I haven't investigated thoroughly, but I think it may be empty by default and then is filled in if you click the gear, set a path, and exit the Hub.
Suggestion: Create a GetHubInstallPath helper function that returns the default directory, overridden by the secondaryInstallPath.json (if non-empty), gated by a Get-OperatingSystem check.
Workaround option: Create a hard link from the default install location to the location where you have configured Unity Hub to store installs.
For example: mklink /J "c:\Program Files\Unity\Hub\Editor" "d:\Program Files\Unity\Hub\Editor"
This will cause UnitySetup to see your installs on the d: drive.
function Get-UnityHubLocation { return (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Unity Technologies\Hub').InstallLocation }
function Get-UnityInstallPath {
$installPath = (Get-UnityHubLocation)+'\Editor'
if(Test-Path ($env:APPDATA+'\UnityHub\secondaryInstallPath.json') -PathType Leaf) {
$tmp = Get-Content ($env:APPDATA+'\UnityHub\secondaryInstallPath.json')
if($tmp) { $installPath = $tmp.Substring(1, $tmp.Length - 2).Replace('\\','\') }
}
return $installPath
}
In #136, we have UnitySetup installing into the same default location as the Unity Hub. This is good because we'd like UnitySetup and the Hub to see each other's editor installs.
However, in Unity Hub users can change their editor install location by clicking the gear icon. UnitySetup should check the Unity Hub setting so that UnitySetup integrates smoothly for users who have changed this Hub setting.