Beispiel #1
0
        void ShowPreviewPackageInUseMenu(Rect rect)
        {
            var menu = new GenericMenu();

            // Here hide the button : reappear after creating a new unity project.
            menu.AddItem(EditorGUIUtility.TrTextContent("Dismiss"), false, () =>
            {
                m_SettingsProxy.dismissPreviewPackagesInUse = true;
                m_SettingsProxy.Save();
            });
            menu.AddSeparator("");

            // Here we open the package manager, In-Project open and search field have experimental.
            menu.AddItem(EditorGUIUtility.TrTextContent("Show Experimental Packages..."), false, () =>
            {
                PackageManagerWindow.SelectPackageAndFilterStatic(string.Empty, PackageFilterTab.InProject, true, "experimental");
            });
            menu.AddSeparator("");

            // Here we go to the link explaining why we see this...
            menu.AddItem(EditorGUIUtility.TrTextContent("Why am I seeing this?"), false, () =>
            {
                m_ApplicationProxy.OpenURL($"https://docs.unity3d.com/{m_ApplicationProxy.shortUnityVersion}/Documentation/Manual/pack-exp.html");
            });

            menu.DropDown(rect, true);
        }
Beispiel #2
0
        internal override void OnHeaderControlsGUI()
        {
            base.OnHeaderControlsGUI();

            if (targets.Length > 1)
            {
                return;
            }

            var previousEnabled = GUI.enabled;

            PackageManifest manifest = null;

            if (m_Package?.state == PackageState.InDevelopment && (m_Version?.isInstalled ?? false))
            {
                manifest = m_AssetDatabase.LoadAssetAtPath <PackageManifest>($"{m_Version.packageInfo.assetPath}/package.json");
            }
            GUI.enabled = manifest != null;
            if (GUILayout.Button(Styles.editPackage, EditorStyles.miniButton))
            {
                m_Selection.activeObject = manifest;
            }

            GUI.enabled = m_Package != null && m_Version != null;
            if (GUILayout.Button(Styles.viewInPackageManager, EditorStyles.miniButton))
            {
                PackageManagerWindow.SelectPackageAndFilterStatic(m_Package.Is(PackageType.AssetStore) ? m_Version.packageUniqueId : m_Version.uniqueId);
            }
            GUI.enabled = previousEnabled;
        }
Beispiel #3
0
        private static void OnListOperation(IOperation operation)
        {
            var listOperation = operation as UpmListOperation;

            if (listOperation.isOfflineMode)
            {
                listOperation.onProcessResult += (request) =>
                {
                    var upmClient = ServicesContainer.instance.Resolve <UpmClient>();
                    upmClient.onListOperation -= OnListOperation;

                    // Package Manager Window always seems to default to name ascending order
                    var packages = request.Result;

                    var entitlementErrorPackage = packages.Where(p => p.entitlements?.isAllowed == false ||
                                                                 p.errors.Any(error => error.message.Contains("You do not have a subscription for this package")))
                                                  .OrderBy(p => p.displayName ?? p.name)
                                                  .FirstOrDefault();

                    if (entitlementErrorPackage != null)
                    {
                        PackageManagerWindow.OpenPackageManager(entitlementErrorPackage.name);
                    }
                };
            }
        }
        void ShowUserMenu(Rect dropDownRect)
        {
            var menu = new GenericMenu();

            menu.AddItem(EditorGUIUtility.TrTextContent("Dismiss"), false, () =>
            {
                m_SettingsProxy.dismissPreviewPackagesInUse = true;
                m_SettingsProxy.Save();
                style.display = DisplayStyle.None;
            });
            menu.AddSeparator("");

            menu.AddItem(EditorGUIUtility.TrTextContent("Show Experimental Packages..."), false, () =>
            {
                PackageManagerWindow.SelectPackageAndFilterStatic(string.Empty, PackageFilterTab.InProject, true, "experimental");
            });
            menu.AddSeparator("");

            menu.AddItem(EditorGUIUtility.TrTextContent("Why am I seeing this?"), false, () =>
            {
                m_ApplicationProxy.OpenURL($"https://docs.unity3d.com/{m_ApplicationProxy.shortUnityVersion}/Documentation/Manual/pack-exp.html");
            });

            menu.DropDown(dropDownRect, true);
        }
Beispiel #5
0
        private static Button CreateLink(IPackageVersion version)
        {
            var featureSetLink = new Button(() => { PackageManagerWindow.OpenPackageManager(version.name); });

            featureSetLink.AddClasses("link featureSetLink");
            featureSetLink.text = version.displayName;
            return(featureSetLink);
        }
        internal override void OnHeaderControlsGUI()
        {
            base.OnHeaderControlsGUI();

            // We want to have this button enabled even for immutable package
            var previousEnabled = GUI.enabled;

            GUI.enabled = packageState != null && packageState.isValidFile && targets.Length == 1;
            if (GUILayout.Button(Styles.viewInPackageManager, EditorStyles.miniButton))
            {
                PackageManagerWindow.SelectPackageAndFilterStatic(packageState.info.packageName.completeName);
            }
            GUI.enabled = previousEnabled;
        }
        void SetupPackageInstall(VisualElement serviceRoot, SingleService singleService)
        {
            serviceRoot.AddManipulator(m_ClickableByServiceName[singleService.name]);

            var installButton          = serviceRoot.Q <Button>(className: k_ServicePackageInstallClassName);
            var installButtonContainer = serviceRoot.Q(className: k_ServicePackageInstallContainerClassName);

            installButtonContainer.style.display = DisplayStyle.None;

            if (singleService.isPackage && (singleService.packageId != null) && (m_PackageCollection != null))
            {
                SetServiceToUninstalledState(installButton, serviceRoot, singleService);
                bool packageFound = false;
                foreach (var info in m_PackageCollection)
                {
                    if (info.packageId.Contains(singleService.packageId))
                    {
                        packageFound = true;
                        SetServiceToInstalledState(installButton, serviceRoot, singleService);
                        break;
                    }
                }

                if (!packageFound)
                {
                    SetServiceToUninstalledState(installButton, serviceRoot, singleService);

                    installButtonContainer.style.display = DisplayStyle.Flex;
                    installButton.clicked += () =>
                    {
                        var packageId = singleService.packageId;
                        EditorAnalytics.SendOpenPackManFromServiceSettings(new ServicesProjectSettings.OpenPackageManager()
                        {
                            packageName = packageId
                        });
                        PackageManagerWindow.OpenPackageManager(packageId);
                    };
                }
            }
        }
        public void OnAddMenuCreate(DropdownMenu menu)
        {
            menu.AppendSeparator("");

            menu.AppendAction("Create Package...", a =>
            {
                var defaultName              = PackageCreator.GenerateUniquePackageDisplayName("New Package");
                var createPackage            = new PackagesAction("Create", defaultName);
                createPackage.actionClicked += displayName =>
                {
                    createPackage.Hide();
                    var packagePath = PackageCreator.CreatePackage("Packages/" + displayName);
                    PackageManagerWindowAnalytics.SendEvent("createPackage");
                    AssetDatabase.Refresh();
#if UNITY_2020_1_OR_NEWER
                    EditorApplication.delayCall += () => Window.Open(displayName);
#else
                    EditorApplication.delayCall += () =>
                    {
                        var path = Path.Combine(packagePath, "package.json");
                        var o    = AssetDatabase.LoadMainAssetAtPath(path);
                        if (o != null)
                        {
                            Selection.activeObject = o;
                        }

                        PackageManagerWindow.SelectPackageAndFilter(displayName, PackageFilterTab.InDevelopment, true);
                    };
#endif
                };

                var parent = EditorWindow.GetWindow <PackageManagerWindow>()
                             .rootVisualElement.Q <PackageManagerToolbar>("topMenuToolbar")
                             .parent;
                parent.Add(createPackage);
                createPackage.Show();
            }, a => DropdownMenuAction.Status.Normal);
        }
Beispiel #9
0
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void ShowAddPackageDialog(object sender, EventArgs e)
        {
            if (HasActiveLoadedSupportedProject)
            {
                var window = new PackageManagerWindow();
                try {
                    window.ShowModal();
                }
                catch (TargetInvocationException exception) {
                    MessageHelper.ShowErrorMessage(
                        (exception.InnerException ?? exception).Message,
                        NuGet.Dialog.Resources.Dialog_MessageBoxTitle);

                    ExceptionHelper.WriteToActivityLog(exception.InnerException ?? exception);
                }
            }
            else
            {
                // show error message when no supported project is selected.
                Project project     = _dte.GetActiveProject();
                string  projectName = project != null ? project.Name : String.Empty;

                string errorMessage;
                if (String.IsNullOrEmpty(projectName))
                {
                    errorMessage = Resources.NoProjectSelected;
                }
                else
                {
                    errorMessage = String.Format(CultureInfo.CurrentCulture, VsResources.DTE_ProjectUnsupported, projectName);
                }

                MessageHelper.ShowWarningMessage(
                    errorMessage,
                    NuGet.Dialog.Resources.Dialog_MessageBoxTitle);
            }
        }
        private void OnDialogWindowClosed(object sender, EventArgs e)
        {
            explorer.Providers.Clear();

            // flush output messages to the Output console at once when the dialog is closed.
            _smartOutputConsoleProvider.Flush();

            CurrentInstance = null;
        }
Beispiel #11
0
 static void OpenPackageManagerOnServicesFilter()
 {
     EditorGameServicesAnalytics.SendTopMenuExploreEvent();
     PackageManagerWindow.OpenPackageManagerOnFilter(ServicesConstants.ExploreServicesPackageManagerFilter);
 }
        private void OnDialogWindowClosed(object sender, EventArgs e)
        {
            foreach (PackagesProviderBase provider in explorer.Providers)
            {
                // give each provider a chance to clean up itself
                provider.Dispose();
            }

            explorer.Providers.Clear();

            // flush output messages to the Output console at once when the dialog is closed.
            _smartOutputConsoleProvider.Flush();

            CurrentInstance = null;
        }
 private void OnDialogWindowLoaded(object sender, RoutedEventArgs e)
 {
     // HACK: Keep track of the currently open instance of this class.
     CurrentInstance = this;
 }
Beispiel #14
0
 public static void ShowPackageManagerWindow(Form owner)
 {
     using var packageManagerWindow = new PackageManagerWindow();
     packageManagerWindow.ShowDialog(owner);
 }
 /// <summary>
 /// Called when coming back from the Options dialog
 /// </summary>
 private static void OnActivated(Project project)
 {
     var window = new PackageManagerWindow(project);
     try
     {
         window.ShowModal();
     }
     catch (TargetInvocationException exception)
     {
         MessageHelper.ShowErrorMessage(exception, NuGet.Dialog.Resources.Dialog_MessageBoxTitle);
         ExceptionHelper.WriteToActivityLog(exception);
     }
 }
        private void OnDialogWindowClosed(object sender, EventArgs e)
        {
            foreach (PackagesProviderBase provider in explorer.Providers)
            {
                // give each provider a chance to clean up itself
                provider.Dispose();
            }

            explorer.Providers.Clear();

            // flush output messages to the Output console at once when the dialog is closed.
            _smartOutputConsoleProvider.Flush();

            _updateAllUIService.DisposeElement();

            if (_httpClientEvents != null)
            {
                _httpClientEvents.SendingRequest -= OnSendingRequest;
            }

            RemoveUpdateBar();
            RemoveRestoreBar();

            CurrentInstance = null;
        }
        private void RefreshSelection(IPackageVersion version = null)
        {
            var selectedDependencyPackageId = m_PackageManagerPrefs.selectedFeatureDependency;

            if (version == null)
            {
                var dependencies = m_FeatureVersion?.dependencies;
                if (dependencies?.Any() != true)
                {
                    return;
                }

                if (string.IsNullOrEmpty(selectedDependencyPackageId) || !dependencies.Any(d => d.name == selectedDependencyPackageId))
                {
                    selectedDependencyPackageId = dependencies[0].name;
                    m_PackageManagerPrefs.selectedFeatureDependency = selectedDependencyPackageId;
                }
                version = m_PackageDatabase.GetPackageInFeatureVersion(selectedDependencyPackageId);
            }

            // If the package is not installed and undiscoverable, we have to display the package's ID name (ex: com.unity.adaptiveperformance.samsung.android)
            // and hide other elements in the package view
            var showElementsInDetailsView = version != null;

            UIUtils.SetElementDisplay(dependencyVersion, showElementsInDetailsView);
            UIUtils.SetElementDisplay(dependencyLink, showElementsInDetailsView);
            UIUtils.SetElementDisplay(dependencyInfoBox, showElementsInDetailsView);

            foreach (var item in dependencyList.Children().OfType <FeatureDependencyItem>())
            {
                item.EnableInClassList(k_SelectedClassName, item.packageName == selectedDependencyPackageId);
            }

            dependencyTitle.value = version?.displayName ?? selectedDependencyPackageId;
            dependencyDesc.value  = version?.description ?? L10n.Tr("This package will be automatically installed with this feature.");

            if (!showElementsInDetailsView)
            {
                return;
            }

            var installedPackageVersion = m_PackageDatabase.GetPackage(version)?.versions.installed;

            dependencyVersion.value = installedPackageVersion != null && installedPackageVersion.versionId != version?.versionId ? string.Format(L10n.Tr("Version {0} (Installed {1})"), version.versionString, installedPackageVersion.versionString) : string.Format(L10n.Tr("Version {0}"), version.versionString);

            var featureState = GetFeatureState(version);

            versionState.ClearClassList();
            if (featureState == FeatureState.Info)
            {
                versionState.AddToClassList(featureState.ToString().ToLower());
                versionState.tooltip = string.Format(L10n.Tr("Using version {0} because at least one other package or feature depends on it"), installedPackageVersion.versionString);
            }

            var tab = PackageFilterTab.UnityRegistry;

            if (version.isDirectDependency)
            {
                tab = PackageFilterTab.InProject;
            }
            dependencyLink.clickable.clicked += () => PackageManagerWindow.SelectPackageAndFilterStatic(version.name, tab);

            UIUtils.SetElementDisplay(dependencyInfoBox, featureState == FeatureState.Customized);
            if (installedPackageVersion?.HasTag(PackageTag.Custom) ?? false)
            {
                m_Link = "fs-details.html";
                dependencyInfoBox.text = L10n.Tr("This package has been customized.");
            }
            else
            {
                m_Link = "upm-ui-remove.html";
                dependencyInfoBox.text = L10n.Tr("This package has been manually changed.");
            }
        }
Beispiel #18
0
 private void OnLaunchPackageManagerButtonClicked()
 {
     PackageManagerWindow.OpenPackageManager(null);
 }
Beispiel #19
0
 static void OpenServicesDiscoveryWindow(Action analyticTrackingAction = null)
 {
     analyticTrackingAction?.Invoke();
     PackageManagerWindow.OpenPackageManagerOnFilter(ServicesConstants.ExploreServicesPackageManagerFilter);
 }
 public void PackageManagerOpen() => PackageManagerWindow.OpenPackageManager(null);