unitysetup.powershell icon indicating copy to clipboard operation
unitysetup.powershell copied to clipboard

UnitySetup should respect the Unity Hub's install path user setting

Open ForrestTrepte opened this issue 6 years ago • 3 comments

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.

ForrestTrepte avatar Jan 17 '19 01:01 ForrestTrepte

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.

ForrestTrepte avatar Jan 17 '19 01:01 ForrestTrepte

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.

ForrestTrepte avatar Mar 26 '19 19:03 ForrestTrepte

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
}

OgreTransporter avatar Jun 16 '21 13:06 OgreTransporter