private void OnPackagesChanged(IEnumerable <IPackage> added, IEnumerable <IPackage> removed, IEnumerable <IPackage> preUpdated, IEnumerable <IPackage> postUpdate)
        {
            var selectedPackageUniqueId = packageSelectionObject?.packageUniqueId;

            if (string.IsNullOrEmpty(selectedPackageUniqueId))
            {
                return;
            }
            if (added.Concat(removed).Concat(preUpdated).Any(p => p.uniqueId == selectedPackageUniqueId))
            {
                m_PackageDatabase.GetPackageAndVersion(packageSelectionObject.packageUniqueId, packageSelectionObject.versionUniqueId, out m_Package, out m_Version);
            }
        }
Esempio n. 2
0
        private void ShowPackages(bool updateScrollPosition)
        {
            UIUtils.SetElementDisplay(scrollView, true);
            UIUtils.SetElementDisplay(emptyArea, false);

            var page                = m_PageManager.GetCurrentPage();
            var selectedVersion     = page.GetSelectedVersion();
            var selectedVisualState = selectedVersion != null?page.GetVisualState(selectedVersion.packageUniqueId) : null;

            if (selectedVisualState?.visible != true)
            {
                var firstVisible = page.visualStates.FirstOrDefault(v => v.visible);
                if (firstVisible != null)
                {
                    IPackage        package;
                    IPackageVersion version;
                    m_PackageDatabase.GetPackageAndVersion(firstVisible.packageUniqueId, firstVisible.selectedVersionId, out package, out version);
                    m_PageManager.SetSelected(package, version);
                }
                else
                {
                    m_PageManager.ClearSelection();
                }
            }

            if (updateScrollPosition)
            {
                ScrollIfNeeded();
            }
        }
        public override void OnInspectorGUI()
        {
            if (packageSelectionObject == null)
            {
                EditorGUILayout.HelpBox(L10n.Tr("This package is not accessible anymore."), MessageType.Error);
                return;
            }

            if (m_Package == null || m_Version == null)
            {
                m_PackageDatabase.GetPackageAndVersion(packageSelectionObject.packageUniqueId, packageSelectionObject.versionUniqueId, out m_Package, out m_Version);
                if (m_Package == null || m_Version == null)
                {
                    EditorGUILayout.HelpBox(L10n.Tr("This package is not accessible anymore."), MessageType.Error);
                    return;
                }

                var immutable = true;
                m_ShouldBeEnabled = true;
                if (!m_Version.isInstalled || AssetDatabase.GetAssetFolderInfo("Packages/" + m_Package.name, out var rootFolder, out immutable))
                {
                    m_ShouldBeEnabled = !immutable;
                }
            }

            var dependencies = new List <DependencyInfo>();

            if (m_Version.dependencies != null)
            {
                dependencies.AddRange(m_Version.dependencies);
            }
            m_List = new ReorderableList(dependencies, typeof(DependencyInfo), false, true, false, false)
            {
                drawElementCallback = DrawDependencyListElement,
                drawHeaderCallback  = DrawDependencyHeaderElement,
                elementHeight       = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing
            };

            var previousEnabled = GUI.enabled;

            GUI.enabled = m_ShouldBeEnabled;

            // Package information
            GUILayout.Label(Styles.information, EditorStyles.boldLabel);
            DoPackageInformationLayout();

            // Package description
            GUILayout.Label(Styles.description, EditorStyles.boldLabel);
            DoPackageDescriptionLayout();

            // Package dependencies
            GUILayout.Label(Styles.dependencies, EditorStyles.boldLabel);
            m_List.DoLayoutList();

            GUI.enabled = previousEnabled;
        }
Esempio n. 4
0
        private void OnEditorSelectionChanged()
        {
            var packageSelectionObject = m_Selection.activeObject as PackageSelectionObject;

            if (packageSelectionObject == null)
            {
                return;
            }

            IPackage        package;
            IPackageVersion version;

            m_PackageDatabase.GetPackageAndVersion(packageSelectionObject.packageUniqueId, packageSelectionObject.versionUniqueId, out package, out version);
            if (package == null || version == null)
            {
                return;
            }

            var tab = FindTab(package, version);

            m_PackageFiltering.currentFilterTab = tab;
            SetSelected(package, version);
        }
Esempio n. 5
0
        public void GetSelectedPackageAndVersion(out IPackage package, out IPackageVersion version)
        {
            var selected = GetVisualState(m_SelectedUniqueIds.FirstOrDefault());

            m_PackageDatabase.GetPackageAndVersion(selected?.packageUniqueId, selected?.selectedVersionId, out package, out version);
        }