Skip to content

Commit c614492

Browse files
committed
add support for 2022.x custom asset store downloads location, fixes #73
1 parent c52e739 commit c614492

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,7 @@ private void ChkAllowSingleInstanceOnly_CheckedChanged(object sender, RoutedEven
18271827

18281828
private void BtnAssetPackages_Click(object sender, RoutedEventArgs e)
18291829
{
1830+
Tools.OpenCustomAssetPath();
18301831
Tools.OpenAppdataSpecialFolder("../Roaming/Unity/Asset Store-5.x");
18311832
}
18321833

Diff for: UnityLauncherPro/Tools.cs

+37-2
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,8 @@ public static string ParseDownloadURLFromWebpage(string version, bool preferFull
829829
else
830830
{
831831
// TODO version here is actually HASH
832-
url = $"https://beta.unity3d.com/download/{version}/download.html";
832+
string hash = version;
833+
url = $"https://beta.unity3d.com/download/{hash}/download.html";
833834

834835
//Console.WriteLine(url);
835836

@@ -838,7 +839,7 @@ public static string ParseDownloadURLFromWebpage(string version, bool preferFull
838839
//Console.WriteLine(version);
839840
if (string.IsNullOrEmpty(version))
840841
{
841-
Console.WriteLine("Failed to get version number from hash: " + version);
842+
SetStatus("Failed to get version (" + version + ") number from hash: " + hash);
842843
return null;
843844
}
844845
}
@@ -2218,6 +2219,40 @@ internal static void SaveProjectSettings(Project proj, string customEnvVars)
22182219
Console.WriteLine(fullPath);
22192220
}
22202221
}
2222+
2223+
internal static void OpenCustomAssetPath()
2224+
{
2225+
// check if custom asset folder is used, then open both *since older versions might have assets in old folder
2226+
string keyPath = @"SOFTWARE\Unity Technologies\Unity Editor 5.x";
2227+
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyPath))
2228+
{
2229+
if (key == null) return;
2230+
// Enumerate subkeys
2231+
foreach (string valueName in key.GetValueNames())
2232+
{
2233+
// Check if the subkey matches the desired pattern
2234+
if (Regex.IsMatch(valueName, @"AssetStoreCacheRootPath_h\d+") == false) continue;
2235+
2236+
string customAssetPath = "";
2237+
var valueKind = key.GetValueKind(valueName);
2238+
2239+
if (valueKind == RegistryValueKind.Binary)
2240+
{
2241+
byte[] bytes = (byte[])key.GetValue(valueName);
2242+
customAssetPath = Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1);
2243+
}
2244+
else // should be string then
2245+
{
2246+
customAssetPath = (string)key.GetValue(valueName);
2247+
}
2248+
2249+
if (string.IsNullOrEmpty(customAssetPath) == false && Directory.Exists(customAssetPath))
2250+
{
2251+
Tools.LaunchExplorer(Path.Combine(customAssetPath, "Asset Store-5.x"));
2252+
}
2253+
}
2254+
}
2255+
}
22212256
} // class
22222257

22232258
} // namespace

0 commit comments

Comments
 (0)