private static string GetFileURL(string packageId, string resolvedPath, string filePath) { if (string.IsNullOrEmpty(filePath) || string.IsNullOrEmpty(packageId) || string.IsNullOrEmpty(resolvedPath)) { return(string.Empty); } var repoUrl = GetRepoHttpUrl(packageId); var hash = GetRevisionHash(resolvedPath); var blob = PackageManagerSettings.GetHostData(packageId).Blob; return($"{repoUrl}/{blob}/{hash}/{filePath}"); }
/// <summary> /// Called by the Package Manager UI when the package selection changed. /// </summary> /// <param name="packageInfo">The newly selected package information (can be null)</param> void IPackageManagerExtension.OnPackageSelectionChange(PackageInfo packageInfo) { InitializeUI(); if (!_initialized || packageInfo == null || _packageInfo == packageInfo) { return; } _packageInfo = packageInfo; var isGit = packageInfo.source == PackageSource.Git; UIUtilities.SetElementDisplay(_gitDetailActions, isGit); UIUtilities.SetElementDisplay(_originalDetailActions, !isGit); UIUtilities.SetElementDisplay(_detailControls.Q("", "popupField"), !isGit); UIUtilities.SetElementDisplay(_updateButton, isGit); UIUtilities.SetElementDisplay(_versionPopup, isGit); UIUtilities.SetElementDisplay(_originalAddButton, false); UIUtilities.SetElementDisplay(_addButton, true); if (isGit) { _updateButton.text = "Update to"; _versionPopup.SetEnabled(false); _updateButton.SetEnabled(false); GitUtilities.GetRefs(UnityPackageUtilities.GetRepoHttpUrl(_packageInfo.packageId), _refs, CheckCurrentRef); SetVersion(_currentRefName); EditorApplication.delayCall += DisplayDetailControls; _currentHostData = PackageManagerSettings.GetHostData(_packageInfo.packageId); _hostingIcon.tooltip = $"View on {_currentHostData.Name}"; _hostingIcon.style.backgroundImage = EditorGUIUtility.isProSkin ? _currentHostData.LogoLight : _currentHostData.LogoDark; } }