private void ShowOthersVersion() { if (m_Version?.package == null) { return; } m_PageManager.SetSeeAllVersions(m_Version.package, true); PackageManagerWindowAnalytics.SendEvent("seeAllVersions", m_Version.package.uniqueId); Refresh(m_Version); }
private void DelayedSearchEvent() { if (DateTime.Now.Ticks - m_SearchTextChangeTimestamp > k_SearchEventDelayTicks) { EditorApplication.update -= DelayedSearchEvent; var value = searchToolbar.value.Trim(); m_PackageFiltering.currentSearchText = value; if (!string.IsNullOrEmpty(value)) { PackageManagerWindowAnalytics.SendEvent("search"); } } }
protected override bool TriggerAction(IPackageVersion version) { if (version.HasTag(PackageTag.Custom)) { if (!m_Application.DisplayDialog(L10n.Tr("Unity Package Manager"), L10n.Tr("You will lose all your changes (if any) if you delete a package in development. Are you sure?"), L10n.Tr("Yes"), L10n.Tr("No"))) { return(false); } m_PackageDatabase.RemoveEmbedded(version.package); PackageManagerWindowAnalytics.SendEvent("removeEmbedded", version.uniqueId); return(true); } return(false); }
protected override bool TriggerAction(IPackageVersion version) { IPackage[] packageToUninstall = null; if (version.HasTag(PackageTag.Feature)) { var customizedDependencies = m_PackageDatabase.GetCustomizedDependencies(version, true); if (customizedDependencies.Any()) { var packageNameAndVersions = string.Join("\n\u2022 ", customizedDependencies.Select(package => $"{package.displayName} - {package.versions.lifecycleVersion.version}").ToArray()); var title = string.Format(L10n.Tr("Installing {0}"), version.package.GetDescriptor()); var message = customizedDependencies.Length == 1 ? string.Format( L10n.Tr("This {0} includes a package version that is different from what's already installed. Would you like to reset the following package to the required version?\n\u2022 {1}"), version.package.GetDescriptor(), packageNameAndVersions) : string.Format( L10n.Tr("This {0} includes package versions that are different from what are already installed. Would you like to reset the following packages to the required versions?\n\u2022 {1}"), version.package.GetDescriptor(), packageNameAndVersions); var result = m_Application.DisplayDialogComplex("installPackageWithCustomizedDependencies", title, message, L10n.Tr("Install and Reset"), L10n.Tr("Cancel"), L10n.Tr("Install Only")); if (result == 1) // Cancel { return(false); } if (result == 0) // Install and reset { packageToUninstall = customizedDependencies; } } } if (packageToUninstall?.Any() == true) { m_PackageDatabase.InstallAndResetDependencies(version, packageToUninstall); PackageManagerWindowAnalytics.SendEvent("installAndReset", version.uniqueId); } else { m_PackageDatabase.Install(version); var installRecommended = version.package.versions.recommended == version ? "Recommended" : "NonRecommended"; var eventName = $"installNew{installRecommended}"; PackageManagerWindowAnalytics.SendEvent(eventName, version.uniqueId); } return(true); }
public void AddDropdownItem(DropdownMenu menu, int value) { var textValue = value == (int)AssetsToLoad.All ? k_All : value.ToString(); textValue = L10n.Tr(textValue); menu.AppendAction(textValue, a => { loadAssetsDropdown.text = textValue; m_SettingsProxy.loadAssets = value; m_SettingsProxy.Save(); UpdateLoadBarMessage(); LoadItemsClicked(); UpdateMenu(); PackageManagerWindowAnalytics.SendEvent($"load {value}"); }, a => m_SettingsProxy.loadAssets == value ? DropdownMenuAction.Status.Checked : DropdownMenuAction.Status.Normal); }
private void InstallByNameAndVersion(string packageName, string packageVersion = null) { var packageId = string.IsNullOrEmpty(packageVersion) ? packageName : $"{packageName}@{packageVersion}"; m_UpmClient.AddById(packageId); PackageManagerWindowAnalytics.SendEvent("addByNameAndVersion", packageId); Close(); var package = m_PackageDatabase.GetPackage(packageName); if (package != null) { m_PackageFiltering.currentFilterTab = m_PageManager.FindTab(package); m_PageManager.SetSelected(package, package.versions?.FirstOrDefault(v => v.versionString == packageVersion)); } }
public static void SendEvent(string action, string packageId = null, IEnumerable <string> packageIds = null) { var servicesContainer = ServicesContainer.instance; var editorAnalyticsProxy = servicesContainer.Resolve <EditorAnalyticsProxy>(); if (!editorAnalyticsProxy.RegisterEvent(k_EventName)) { return; } // remove sensitive part of the id: file path or url is not tracked if (!string.IsNullOrEmpty(packageId)) { packageId = Regex.Replace(packageId, "(?<package>[^@]+)@(?<protocol>[^:]+):.+", "${package}@${protocol}"); } var packageFiltering = servicesContainer.Resolve <PackageFiltering>(); var settingsProxy = servicesContainer.Resolve <PackageManagerProjectSettingsProxy>(); // Add the name of the sub page into the filter name for now var filterName = packageFiltering.currentFilterTab.ToString(); var page = servicesContainer.Resolve <PageManager>().GetCurrentPage(); var subPage = page.subPages.Skip(1).Any() ? page.currentSubPage : null; if (!string.IsNullOrEmpty(subPage?.name)) { filterName += "/" + subPage.name; } var parameters = new PackageManagerWindowAnalytics { action = action, package_id = packageId ?? string.Empty, package_ids = packageIds?.ToArray() ?? new string[0], search_text = packageFiltering.currentSearchText, filter_name = filterName, window_docked = EditorWindow.GetWindowDontShow <PackageManagerWindow>()?.docked ?? false, dependencies_visible = settingsProxy.enablePackageDependencies, preview_visible = settingsProxy.enablePreReleasePackages }; editorAnalyticsProxy.SendEventWithLimit(k_EventName, parameters); }
private static void OnConfigureClicked(PackageSelectionArgs args) { var database = ServicesContainer.instance.Resolve <PackageDatabase>(); var package = database.GetPackage(args.package.uniqueId); var installedVersion = package?.versions?.installed; if (installedVersion == null) { return; } var editorGameService = GetEditorGameServiceField(installedVersion.packageInfo); var configurePath = GetConfigurePathField(editorGameService); if (!string.IsNullOrEmpty(configurePath)) { PackageManagerWindowAnalytics.SendEvent("configureService", args.package.uniqueId); } SettingsService.OpenProjectSettings(configurePath); }
public void OnEnable() { styleSheets.Add(m_ResourceLoader.packageManagerWindowStyleSheet); var root = m_ResourceLoader.GetTemplate("PackageManagerWindow.uxml"); Add(root); cache = new VisualElementCache(root); var newTab = m_PackageManagerPrefs.lastUsedPackageFilter ?? PackageFiltering.k_DefaultFilterTab; // Reset the lock icons when users open a new Package Manager window m_PageManager.GetPage(newTab).ResetUserUnlockedState(); packageDetails.OnEnable(); packageList.OnEnable(); packageManagerToolbar.OnEnable(); packageSubPageFilterBar.OnEnable(); packageStatusbar.OnEnable(); leftColumnContainer.style.flexGrow = m_PackageManagerPrefs.splitterFlexGrow; rightColumnContainer.style.flexGrow = 1 - m_PackageManagerPrefs.splitterFlexGrow; m_PageManager.onRefreshOperationFinish += OnRefreshOperationFinish; m_UnityConnectProxy.onUserLoginStateChange += OnUserLoginStateChange; m_AssetStoreCachePathProxy.onConfigChanged += OnAssetStoreCacheConfigChange; PackageManagerWindowAnalytics.Setup(); EditorApplication.focusChanged += OnFocusChanged; m_Selection.onSelectionChanged += RefreshSelectedInInspectorClass; focusable = true; RegisterCallback <AttachToPanelEvent>(OnAttachToPanel); RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel); RefreshSelectedInInspectorClass(); }
private void Refresh(IPage page = null) { if (page == null) { page = m_PageManager.GetCurrentPage(); } var showOnFilterTab = page.subPages.Skip(1).Any(); UIUtils.SetElementDisplay(this, showOnFilterTab); if (!showOnFilterTab) { return; } Clear(); var currentSubPage = page.currentSubPage; foreach (var subPage in page.subPages) { var button = new Button(); button.text = subPage.displayName; button.clickable.clicked += () => { if (page.currentSubPage == subPage) { return; } page.currentSubPage = subPage; PackageManagerWindowAnalytics.SendEvent("changeSubPage"); }; Add(button); if (subPage == currentSubPage) { button.AddToClassList("active"); } } }
public static void SendEvent(string action, string packageId = null, IEnumerable <string> packageIds = null) { var servicesContainer = ServicesContainer.instance; var editorAnalyticsProxy = servicesContainer.Resolve <EditorAnalyticsProxy>(); if (!editorAnalyticsProxy.RegisterEvent(k_EventName)) { return; } // remove sensitive part of the id: file path or url is not tracked if (!string.IsNullOrEmpty(packageId)) { packageId = Regex.Replace(packageId, "(?<package>[^@]+)@(?<protocol>[^:]+):.+", "${package}@${protocol}"); } var packageFiltering = servicesContainer.Resolve <PackageFiltering>(); var packageManagerPrefs = servicesContainer.Resolve <PackageManagerPrefs>(); var settingsProxy = servicesContainer.Resolve <PackageManagerProjectSettingsProxy>(); var filterName = GetFilterNameWithSubPage(packageFiltering, servicesContainer.Resolve <PageManager>()); var parameters = new PackageManagerWindowAnalytics { action = action, package_id = packageId ?? string.Empty, package_ids = packageIds?.ToArray() ?? new string[0], search_text = packageFiltering.currentSearchText, filter_name = filterName, details_tab = packageManagerPrefs.selectedPackageDetailsTabIdentifier ?? string.Empty, window_docked = EditorWindow.GetWindowDontShow <PackageManagerWindow>()?.docked ?? false, // packages installed as dependency are always visible // we keep the dependencies_visible to not break the analytics dependencies_visible = true, preview_visible = settingsProxy.enablePreReleasePackages }; editorAnalyticsProxy.SendEventWithLimit(k_EventName, parameters); }
public static void SendEvent(PageFilters filters) { var servicesContainer = ServicesContainer.instance; var editorAnalyticsProxy = servicesContainer.Resolve <EditorAnalyticsProxy>(); if (!editorAnalyticsProxy.RegisterEvent(k_EventName)) { return; } var filterTab = PackageManagerWindowAnalytics.GetFilterNameWithSubPage(servicesContainer.Resolve <PackageFiltering>(), servicesContainer.Resolve <PageManager>()); var orderBy = filters.isReverseOrder ? $"{filters.orderBy} (reversed)" : filters.orderBy; var parameters = new PackageManagerFiltersAnalytics { filter_tab = filterTab, order_by = orderBy, status = filters.status, categories = filters.categories.ToArray(), labels = filters.labels.ToArray() }; editorAnalyticsProxy.SendEventWithLimit(k_EventName, parameters); }
private void SetupAdvancedMenu() { toolbarSettingsMenu.tooltip = L10n.Tr("Advanced"); var dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Project Settings"); dropdownItem.action = () => { if (!m_SettingsProxy.advancedSettingsExpanded) { m_SettingsProxy.advancedSettingsExpanded = true; m_SettingsProxy.Save(); } SettingsWindow.Show(SettingsScope.Project, PackageManagerProjectSettingsProvider.k_PackageManagerSettingsPath); PackageManagerWindowAnalytics.SendEvent("advancedProjectSettings"); }; dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Preferences"); dropdownItem.action = () => { SettingsWindow.Show(SettingsScope.User, PackageManagerUserSettingsProvider.k_PackageManagerUserSettingsPath); PackageManagerWindowAnalytics.SendEvent("packageManagerUserSettings"); }; dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.insertSeparatorBefore = true; dropdownItem.text = L10n.Tr("Manual resolve"); dropdownItem.action = () => { if (!EditorApplication.isPlaying) { m_UpmClient.Resolve(); } }; dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.insertSeparatorBefore = true; dropdownItem.text = L10n.Tr("Reset Packages to defaults"); dropdownItem.action = () => { EditorApplication.ExecuteMenuItem(k_ResetPackagesMenuPath); m_PageManager.Refresh(RefreshOptions.UpmListOffline); PackageManagerWindowAnalytics.SendEvent("resetToDefaults"); }; if (Unsupported.IsDeveloperBuild()) { dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.insertSeparatorBefore = true; dropdownItem.text = L10n.Tr("Reset Package Database"); dropdownItem.action = () => { PackageManagerWindow.instance?.Close(); m_PageManager.Reload(); ServicesContainer.instance.Resolve <AssetStoreCallQueue>().ClearFetchDetails(); }; dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Reset Stylesheets"); dropdownItem.action = () => { PackageManagerWindow.instance?.Close(); m_ResourceLoader.Reset(); }; } }
protected override bool TriggerAction(IList <IPackageVersion> versions) { m_PageManager.SetPackagesUserUnlockedState(versions.Select(v => v.packageUniqueId), true); PackageManagerWindowAnalytics.SendEvent("unlock", packageIds: versions.Select(v => v.packageUniqueId)); return(true); }
protected override bool TriggerAction(IPackageVersion version) { var result = 0; if (version.HasTag(PackageTag.BuiltIn)) { if (!m_PackageManagerPrefs.skipDisableConfirmation) { result = m_Application.DisplayDialogComplex(L10n.Tr("Disable Built-In Package"), L10n.Tr("Are you sure you want to disable this built-in package?"), L10n.Tr("Disable"), L10n.Tr("Cancel"), L10n.Tr("Never ask")); } } else { var isPartOfFeature = m_PackageDatabase.GetFeatureDependents(version).Any(featureSet => featureSet.isInstalled); if (isPartOfFeature || !m_PackageManagerPrefs.skipRemoveConfirmation) { var descriptor = version.package.GetDescriptor(); var title = string.Format(L10n.Tr("Removing {0}"), CultureInfo.InvariantCulture.TextInfo.ToTitleCase(descriptor)); if (isPartOfFeature) { var message = string.Format(L10n.Tr("Are you sure you want to remove this {0} that is used by at least one installed feature?"), descriptor); var removeIt = m_Application.DisplayDialog(title, message, L10n.Tr("Remove"), L10n.Tr("Cancel")); result = removeIt ? 0 : 1; } else { var message = string.Format(L10n.Tr("Are you sure you want to remove this {0}?"), descriptor); result = m_Application.DisplayDialogComplex(title, message, L10n.Tr("Remove"), L10n.Tr("Cancel"), L10n.Tr("Never ask")); } } } // Cancel if (result == 1) { return(false); } // Do not ask again if (result == 2) { if (version.HasTag(PackageTag.BuiltIn)) { m_PackageManagerPrefs.skipDisableConfirmation = true; } else { m_PackageManagerPrefs.skipRemoveConfirmation = true; } } // If the user is removing a package that is part of a feature set, lock it after removing from manifest // Having this check condition should be more optimal once we implement caching of Feature Set Dependents for each package if (m_PackageDatabase.GetFeatureDependents(version.package.versions.installed)?.Any() == true) { m_PageManager.SetPackagesUserUnlockedState(new List <string> { version.packageUniqueId }, false); } // Remove m_PackageDatabase.Uninstall(version.package); PackageManagerWindowAnalytics.SendEvent("uninstall", version?.uniqueId); return(true); }
protected override bool TriggerAction(IPackageVersion version) { var installedVersion = version.package.versions.installed; var targetVersion = GetTargetVersion(version); if (installedVersion != null && !installedVersion.isDirectDependency && installedVersion != targetVersion) { var featureSetDependents = m_PackageDatabase.GetFeatureDependents(installedVersion); // if the installed version is being used by a Feature Set show the more specific // Feature Set dialog instead of the generic one if (featureSetDependents.Any()) { var message = string.Format(L10n.Tr("Changing a {0} that is part of a feature can lead to errors. Are you sure you want to proceed?"), version.package.GetDescriptor()); if (!m_Application.DisplayDialog(L10n.Tr("Warning"), message, L10n.Tr("Yes"), L10n.Tr("No"))) { return(false); } } else { var message = L10n.Tr("This version of the package is being used by other packages. Upgrading a different version might break your project. Are you sure you want to continue?"); if (!m_Application.DisplayDialog(L10n.Tr("Unity Package Manager"), message, L10n.Tr("Yes"), L10n.Tr("No"))) { return(false); } } } IPackage[] packageToUninstall = null; if (targetVersion.HasTag(PackageTag.Feature)) { var customizedDependencies = m_PackageDatabase.GetCustomizedDependencies(targetVersion, true); if (customizedDependencies.Any()) { var packageNameAndVersions = string.Join("\n\u2022 ", customizedDependencies.Select(package => $"{package.displayName} - {package.versions.lifecycleVersion.version}").ToArray()); var message = customizedDependencies.Length == 1 ? string.Format( L10n.Tr("This {0} includes a package version that is different from what's already installed. Would you like to reset the following package to the required version?\n\u2022 {1}"), version.package.GetDescriptor(), packageNameAndVersions) : string.Format( L10n.Tr("This {0} includes package versions that are different from what are already installed. Would you like to reset the following packages to the required versions?\n\u2022 {1}"), version.package.GetDescriptor(), packageNameAndVersions); var result = m_Application.DisplayDialogComplex(L10n.Tr("Unity Package Manager"), message, L10n.Tr("Install and Reset"), L10n.Tr("Cancel"), L10n.Tr("Install Only")); if (result == 1) // Cancel { return(false); } if (result == 0) // Install and reset { packageToUninstall = customizedDependencies; } } } if (packageToUninstall?.Any() == true) { m_PackageDatabase.InstallAndResetDependencies(targetVersion, packageToUninstall); PackageManagerWindowAnalytics.SendEvent("installAndReset", targetVersion?.uniqueId); } else { m_PackageDatabase.Install(targetVersion); var installRecommended = version.package.versions.recommended == targetVersion ? "Recommended" : "NonRecommended"; var eventName = $"installUpdate{installRecommended}"; PackageManagerWindowAnalytics.SendEvent(eventName, targetVersion?.uniqueId); } return(true); }
private void OnDeselectLockedSelectionsClicked() { m_PageManager.RemoveSelection(m_UnlockFoldout.versions.Select(s => new PackageAndVersionIdPair(s.packageUniqueId, s.uniqueId))); PackageManagerWindowAnalytics.SendEvent("deselectLocked", packageIds: m_UnlockFoldout.versions.Select(v => v.packageUniqueId)); }
public void Refresh(IPackage package, IPackageVersion version) { m_Package = package; m_Version = version; Clear(); if (package == null || version == null) { return; } var leftItems = new VisualElement { classList = { "left" } }; Add(leftItems); // add links from the package foreach (var link in package.links) { if (string.IsNullOrEmpty(link.name) || string.IsNullOrEmpty(link.url)) { continue; } AddToLinks(leftItems, new Button(() => { m_Application.OpenURL(link.url); if (!string.IsNullOrEmpty(link.analyticsEventName)) { PackageManagerWindowAnalytics.SendEvent(link.analyticsEventName, version?.uniqueId); } }) { text = link.name, tooltip = link.url, classList = { k_LinkClass } }, package.links.First() != link); } // add links related to the upm version if (UpmPackageDocs.HasDocs(version)) { AddToLinks(leftItems, new Button(ViewDocClick) { text = k_ViewDocumentationText, classList = { k_LinkClass } }, false); } if (UpmPackageDocs.HasChangelog(version)) { AddToLinks(leftItems, new Button(ViewChangelogClick) { text = k_ViewChangelogText, classList = { k_LinkClass } }); } if (UpmPackageDocs.HasLicenses(version)) { AddToLinks(leftItems, new Button(ViewLicensesClick) { text = k_ViewLicensesText, classList = { k_LinkClass } }); } if (UpmPackageDocs.HasUseCases(version)) { AddToLinks(leftItems, new Button(ViewUseCasesClick) { text = k_ViewUseCasesText, classList = { k_LinkClass } }); } if (UpmPackageDocs.HasDashboard(version)) { AddToLinks(leftItems, new Button(ViewDashboardClick) { text = k_ViewDashboardText, classList = { k_LinkClass } }); } UIUtils.SetElementDisplay(this, childCount != 0); }
public PackageManagerProjectSettingsProvider(string path, SettingsScope scopes, IEnumerable <string> keywords = null) : base(path, scopes, keywords) { activateHandler = (s, element) => { ResolveDependencies(); // Create a child to make sure all the style sheets are not added to the root. rootVisualElement = new ScrollView(); rootVisualElement.StretchToParentSize(); rootVisualElement.AddStyleSheetPath(StylesheetPath.scopedRegistriesSettings); rootVisualElement.AddStyleSheetPath(StylesheetPath.projectSettings); rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? StylesheetPath.stylesheetDark : StylesheetPath.stylesheetLight); rootVisualElement.AddStyleSheetPath(StylesheetPath.stylesheetCommon); rootVisualElement.styleSheets.Add(m_ResourceLoader.packageManagerCommonStyleSheet); element.Add(rootVisualElement); m_GeneralTemplate = EditorGUIUtility.Load(k_GeneralServicesTemplatePath) as VisualTreeAsset; VisualElement newVisualElement = new VisualElement(); m_GeneralTemplate.CloneTree(newVisualElement); rootVisualElement.Add(newVisualElement); cache = new VisualElementCache(rootVisualElement); advancedSettingsFoldout.SetValueWithoutNotify(m_SettingsProxy.advancedSettingsExpanded); m_SettingsProxy.onAdvancedSettingsFoldoutChanged += OnAdvancedSettingsFoldoutChanged; advancedSettingsFoldout.RegisterValueChangedCallback(changeEvent => { if (changeEvent.target == advancedSettingsFoldout) { m_SettingsProxy.advancedSettingsExpanded = changeEvent.newValue; } }); scopedRegistriesSettingsFoldout.SetValueWithoutNotify(m_SettingsProxy.scopedRegistriesSettingsExpanded); m_SettingsProxy.onScopedRegistriesSettingsFoldoutChanged += OnScopedRegistriesSettingsFoldoutChanged; scopedRegistriesSettingsFoldout.RegisterValueChangedCallback(changeEvent => { if (changeEvent.target == scopedRegistriesSettingsFoldout) { m_SettingsProxy.scopedRegistriesSettingsExpanded = changeEvent.newValue; } }); preReleaseInfoBox.Q <Button>().clickable.clicked += () => { m_ApplicationProxy.OpenURL($"https://docs.unity3d.com/{m_ApplicationProxy.shortUnityVersion}/Documentation/Manual/pack-preview.html"); }; enablePreReleasePackages.SetValueWithoutNotify(m_SettingsProxy.enablePreReleasePackages); enablePreReleasePackages.RegisterValueChangedCallback(changeEvent => { var newValue = changeEvent.newValue; if (newValue != m_SettingsProxy.enablePreReleasePackages) { var saveIt = true; if (newValue && !m_SettingsProxy.oneTimeWarningShown) { if (m_ApplicationProxy.DisplayDialog("showPreReleasePackages", L10n.Tr("Show pre-release packages"), k_Message, L10n.Tr("I understand"), L10n.Tr("Cancel"))) { m_SettingsProxy.oneTimeWarningShown = true; } else { saveIt = false; } } if (saveIt) { m_SettingsProxy.enablePreReleasePackages = newValue; m_SettingsProxy.Save(); PackageManagerWindowAnalytics.SendEvent("togglePreReleasePackages"); } } enablePreReleasePackages.SetValueWithoutNotify(m_SettingsProxy.enablePreReleasePackages); }); UIUtils.SetElementDisplay(seeAllPackageVersions, Unsupported.IsDeveloperBuild()); seeAllPackageVersions.SetValueWithoutNotify(m_SettingsProxy.seeAllPackageVersions); seeAllPackageVersions.RegisterValueChangedCallback(changeEvent => { seeAllPackageVersions.SetValueWithoutNotify(changeEvent.newValue); var newValue = changeEvent.newValue; if (newValue != m_SettingsProxy.seeAllPackageVersions) { m_SettingsProxy.seeAllPackageVersions = newValue; m_SettingsProxy.Save(); } }); }; }
protected override bool TriggerAction(IPackageVersion version) { m_PackageDatabase.AbortDownload(version.package); PackageManagerWindowAnalytics.SendEvent("abortDownload", version.packageUniqueId); return(true); }
protected override bool TriggerAction(IList <IPackageVersion> versions) { m_PackageDatabase.AbortDownload(versions.Select(v => v.package)); PackageManagerWindowAnalytics.SendEvent("abortDownload", packageIds: versions.Select(v => v.packageUniqueId)); return(true); }
private void SetupAddMenu() { var dropdownItem = addMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Add package from disk..."); dropdownItem.userData = "AddFromDisk"; dropdownItem.action = () => { var path = m_Application.OpenFilePanelWithFilters(L10n.Tr("Select package on disk"), "", new[] { "package.json file", "json" }); if (string.IsNullOrEmpty(path)) { return; } try { if (m_IOProxy.GetFileName(path) != "package.json") { Debug.Log(L10n.Tr("[Package Manager Window] Please select a valid package.json file in a package folder.")); return; } if (!m_PackageDatabase.isInstallOrUninstallInProgress) { m_PackageDatabase.InstallFromPath(m_IOProxy.GetParentDirectory(path), out var tempPackageId); PackageManagerWindowAnalytics.SendEvent("addFromDisk"); var package = m_PackageDatabase.GetPackage(tempPackageId); if (package != null) { m_PackageFiltering.currentFilterTab = PackageFilterTab.InProject; m_PageManager.SetSelected(package); } } } catch (System.IO.IOException e) { Debug.Log($"[Package Manager Window] Cannot add package from disk {path}: {e.Message}"); } }; dropdownItem = addMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Add package from tarball..."); dropdownItem.userData = "AddFromTarball"; dropdownItem.action = () => { var path = m_Application.OpenFilePanelWithFilters(L10n.Tr("Select package on disk"), "", new[] { "Package tarball", "tgz, tar.gz" }); if (!string.IsNullOrEmpty(path) && !m_PackageDatabase.isInstallOrUninstallInProgress) { m_PackageDatabase.InstallFromPath(path, out var tempPackageId); PackageManagerWindowAnalytics.SendEvent("addFromTarball"); var package = m_PackageDatabase.GetPackage(tempPackageId); if (package != null) { m_PackageFiltering.currentFilterTab = PackageFilterTab.InProject; m_PageManager.SetSelected(package); } } }; dropdownItem = addMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Add package from git URL..."); dropdownItem.userData = "AddFromGit"; dropdownItem.action = () => { var args = new InputDropdownArgs { title = L10n.Tr("Add package from git URL"), iconUssClass = "git", placeholderText = L10n.Tr("URL"), submitButtonText = L10n.Tr("Add"), onInputSubmitted = url => { if (!m_PackageDatabase.isInstallOrUninstallInProgress) { m_PackageDatabase.InstallFromUrl(url); PackageManagerWindowAnalytics.SendEvent("addFromGitUrl", url); var package = m_PackageDatabase.GetPackage(url); if (package != null) { m_PackageFiltering.currentFilterTab = PackageFilterTab.InProject; m_PageManager.SetSelected(package); } } }, windowSize = new Vector2(resolvedStyle.width, 50) }; addMenu.ShowInputDropdown(args); }; dropdownItem = addMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Add package by name..."); dropdownItem.userData = "AddByName"; dropdownItem.action = () => { // Same as above, the worldBound of the toolbar is used rather than the addMenu var rect = GUIUtility.GUIToScreenRect(worldBound); var dropdown = new AddPackageByNameDropdown(m_ResourceLoader, m_PackageFiltering, m_UpmClient, m_PackageDatabase, m_PageManager, PackageManagerWindow.instance) { position = rect }; DropdownContainer.ShowDropdown(dropdown); }; }
protected override void OnTabHeaderClicked(PackageDetailsTabElement tab) { base.OnTabHeaderClicked(tab); PackageManagerWindowAnalytics.SendEvent("changeDetailsTab", m_Version?.uniqueId); }
private void SeeAllVersionsClick() { m_PageManager.SetSeeAllVersions(package, true); PackageManagerWindowAnalytics.SendEvent("seeAllVersions", targetVersion?.uniqueId); }