private void AuthorClick() { var authorLink = m_Version?.authorLink ?? string.Empty; if (!string.IsNullOrEmpty(authorLink)) { m_Application.OpenURL(authorLink); } }
private void AuthorClick() { var authorLink = m_Version?.authorLink ?? string.Empty; if (!string.IsNullOrEmpty(authorLink)) { m_Application.OpenURL(authorLink); PackageManagerWindowAnalytics.SendEvent("viewAuthorLink", m_Version?.uniqueId); } }
public static void OpenWebUrl(string onlineUrl, IPackageVersion version, ApplicationProxy applicationProxy, string analyticsEvent, Action errorCallback) { var request = UnityWebRequest.Head(onlineUrl); try { var operation = request.SendWebRequest(); operation.completed += (op) => { if (request.responseCode >= 200 && request.responseCode < 300) { applicationProxy.OpenURL(onlineUrl); PackageManagerWindowAnalytics.SendEvent($"{analyticsEvent}ValidUrl", version?.uniqueId); } else { errorCallback?.Invoke(); } }; } catch (InvalidOperationException e) { if (e.Message != "Insecure connection not allowed") { throw e; } } }
public static void HandleInvalidOrUnreachableOnlineUrl(string onlineUrl, string offlineDocPath, string docType, string analyticsEvent, IPackageVersion version, IPackage package, ApplicationProxy applicationProxy) { if (!string.IsNullOrEmpty(offlineDocPath)) { applicationProxy.RevealInFinder(offlineDocPath); PackageManagerWindowAnalytics.SendEvent($"{analyticsEvent}OnDisk", version?.uniqueId); return; } if (!string.IsNullOrEmpty(onlineUrl)) { // With the current `UpmPackageDocs.GetDocumentationUrl` implementation, // We'll get invalid url links for non-unity packages on unity3d.com // We want to avoiding opening these kinds of links to avoid confusion. if (!UpmClient.IsUnityUrl(onlineUrl) || package.Is(PackageType.Unity) || version.packageUniqueId.StartsWith("com.unity.")) { applicationProxy.OpenURL(onlineUrl); PackageManagerWindowAnalytics.SendEvent($"{analyticsEvent}UnreachableOrInvalidUrl", version?.uniqueId); return; } } PackageManagerWindowAnalytics.SendEvent($"{analyticsEvent}NotFound", version?.uniqueId); Debug.LogError(string.Format(L10n.Tr("[Package Manager Window] Unable to find valid {0} for this {1}."), docType, package.GetDescriptor())); }
public void Refresh(IPackage package) { m_Package = package; var visible = m_Package?.images.Any() ?? false; UIUtils.SetElementDisplay(this, visible); ClearSupportingImages(); if (!visible) { return; } if (s_LoadingTexture == null) { s_LoadingTexture = (Texture2D)EditorGUIUtility.LoadRequired("Icons/UnityLogo.png"); } if (long.TryParse(m_Package.uniqueId, out long id)) { foreach (var packageImage in m_Package.images) { var image = new Label { classList = { "image" } }; image.OnLeftClick(() => { m_Application.OpenURL(packageImage.url); }); image.style.backgroundImage = s_LoadingTexture; m_ImagesContainer.Add(image); m_AssetStoreCache.DownloadImageAsync(id, packageImage.thumbnailUrl, (retId, texture) => { if (retId.ToString() == m_Package?.uniqueId) { texture.hideFlags = HideFlags.HideAndDontSave; image.style.backgroundImage = texture; } }); } } m_MoreLink.clicked += OnMoreImagesClicked; }
public FeatureDependencies() { ResolveDependencies(); var root = m_ResourceLoader.GetTemplate("FeatureDependencies.uxml"); Add(root); cache = new VisualElementCache(root); SetExpanded(m_PackageManagerPrefs.featureDependenciesExpanded); dependenciesExpander?.RegisterValueChangedCallback(evt => SetExpanded(evt.newValue)); dependencyInfoBox.Q <Button>().clickable.clicked += () => m_Application.OpenURL($"{infoBoxUrl}/{m_Link}"); }
public ScopedRegistriesSettings() { ResolveDependencies(); var root = m_ResourceLoader.GetTemplate("ScopedRegistriesSettings.uxml"); Add(root); cache = new VisualElementCache(root); scopedRegistriesInfoBox.Q <Button>().clickable.clicked += () => { m_ApplicationProxy.OpenURL($"https://docs.unity3d.com/{m_ApplicationProxy.shortUnityVersion}/Documentation/Manual/upm-scoped.html"); }; applyRegistriesButton.clickable.clicked += ApplyChanges; revertRegistriesButton.clickable.clicked += RevertChanges; registryNameTextField.RegisterValueChangedCallback(OnRegistryNameChanged); registryUrlTextField.RegisterValueChangedCallback(OnRegistryUrlChanged); m_NewScopedRegistryLabel = new Label(); m_NewScopedRegistryLabel.AddToClassList(k_NewRegistryClass); m_NewScopedRegistryLabel.OnLeftClick(() => OnRegistryLabelClicked(null)); addRegistryButton.clickable.clicked += AddRegistryClicked; removeRegistryButton.clickable.clicked += RemoveRegistryClicked; addScopeButton.clickable.clicked += AddScopeClicked; removeScopeButton.clickable.clicked += RemoveScopeClicked; m_UpmRegistryClient.onRegistriesModified += OnRegistriesModified; m_UpmRegistryClient.onRegistryOperationError += OnRegistryOperationError; Undo.undoRedoPerformed -= OnUndoRedoPerformed; Undo.undoRedoPerformed += OnUndoRedoPerformed; // on domain reload, it's not guaranteed that the settings have // reloaded the draft object yet- need to wait and do this when // initialization has finished if (draft.IsReady()) { UpdateRegistryList(); UpdateRegistryDetails(); } else { m_SettingsProxy.onInitializationFinished += OnSettingsInitialized; } }
public FeatureDependenciesTab(ResourceLoader resourceLoader, PackageDatabase packageDatabase, PackageManagerPrefs packageManagerPrefs, PackageManagerProjectSettingsProxy settingsProxy, ApplicationProxy applicationProxy) { m_ResourceLoader = resourceLoader; m_PackageDatabase = packageDatabase; m_PackageManagerPrefs = packageManagerPrefs; m_SettingsProxy = settingsProxy; m_Application = applicationProxy; m_Id = k_Id; m_DisplayName = L10n.Tr("Packages Included"); var root = m_ResourceLoader.GetTemplate("FeatureDependencies.uxml"); Add(root); cache = new VisualElementCache(root); dependencyInfoBox.Q <Button>().clickable.clicked += () => m_Application.OpenURL($"{infoBoxUrl}/{m_Link}"); }
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(); } }); }; }
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 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); }) { 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 } }); } var topOffset = false; if (package.Is(PackageType.Feature) && !string.IsNullOrEmpty(GetQuickStartUrl(m_Version))) { var quickStartButton = new Button(ViewQuickStartClick) { name = "quickStart", classList = { "quickStartButton", "right" } }; quickStartButton.Add(new VisualElement { classList = { "quickStartIcon" } }); quickStartButton.Add(new TextElement { text = k_ViewQuickStartText, classList = { "quickStartText" } }); Add(quickStartButton); topOffset = leftItems.childCount == 0; } // Offset the links container to the top when there are no links and only quick start button visible EnableInClassList("topOffset", topOffset); UIUtils.SetElementDisplay(this, childCount != 0); }