Skip to content

Commit

Permalink
add support for 2022.x custom asset store downloads location, fixes #73
Browse files Browse the repository at this point in the history
  • Loading branch information
unitycoder committed Apr 20, 2024
1 parent c52e739 commit c614492
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions UnityLauncherPro/MainWindow.xaml.cs
Expand Up @@ -1827,6 +1827,7 @@ private void ChkAllowSingleInstanceOnly_CheckedChanged(object sender, RoutedEven

private void BtnAssetPackages_Click(object sender, RoutedEventArgs e)
{
Tools.OpenCustomAssetPath();
Tools.OpenAppdataSpecialFolder("../Roaming/Unity/Asset Store-5.x");
}

Expand Down
39 changes: 37 additions & 2 deletions UnityLauncherPro/Tools.cs
Expand Up @@ -829,7 +829,8 @@ public static string ParseDownloadURLFromWebpage(string version, bool preferFull
else
{
// TODO version here is actually HASH
url = $"https://beta.unity3d.com/download/{version}/download.html";
string hash = version;
url = $"https://beta.unity3d.com/download/{hash}/download.html";

//Console.WriteLine(url);

Expand All @@ -838,7 +839,7 @@ public static string ParseDownloadURLFromWebpage(string version, bool preferFull
//Console.WriteLine(version);
if (string.IsNullOrEmpty(version))
{
Console.WriteLine("Failed to get version number from hash: " + version);
SetStatus("Failed to get version (" + version + ") number from hash: " + hash);
return null;
}
}
Expand Down Expand Up @@ -2218,6 +2219,40 @@ internal static void SaveProjectSettings(Project proj, string customEnvVars)
Console.WriteLine(fullPath);
}
}

internal static void OpenCustomAssetPath()
{
// check if custom asset folder is used, then open both *since older versions might have assets in old folder
string keyPath = @"SOFTWARE\Unity Technologies\Unity Editor 5.x";
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyPath))
{
if (key == null) return;
// Enumerate subkeys
foreach (string valueName in key.GetValueNames())
{
// Check if the subkey matches the desired pattern
if (Regex.IsMatch(valueName, @"AssetStoreCacheRootPath_h\d+") == false) continue;

string customAssetPath = "";
var valueKind = key.GetValueKind(valueName);

if (valueKind == RegistryValueKind.Binary)
{
byte[] bytes = (byte[])key.GetValue(valueName);
customAssetPath = Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1);
}
else // should be string then
{
customAssetPath = (string)key.GetValue(valueName);
}

if (string.IsNullOrEmpty(customAssetPath) == false && Directory.Exists(customAssetPath))
{
Tools.LaunchExplorer(Path.Combine(customAssetPath, "Asset Store-5.x"));
}
}
}
}
} // class

} // namespace

0 comments on commit c614492

Please sign in to comment.