Skip to content

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

Open

Description

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.

Activity

  1. ForrestTrepte commented on Jan 17, 2019

    @ForrestTrepte
    ContributorAuthor

    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.

  2. ForrestTrepte commented on Mar 26, 2019

    @ForrestTrepte
    ContributorAuthor

    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.

  3. OgreTransporter commented on Jun 16, 2021

    @OgreTransporter
    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
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions