예제 #1
0
        public void OnEnable()
        {
            var collectionWasNull = Collection == null;

            if (Collection == null)
            {
                Collection = new PackageCollection();
            }

            if (SearchFilter == null)
            {
                SearchFilter = new PackageSearchFilter();
            }

            this.GetRootVisualContainer().AddStyleSheetPath(EditorGUIUtility.isProSkin ? DarkStylePath : LightStylePath);
            // Temporarly fix for case 1075335 (UIElements)
            this.GetRootVisualContainer().style.positionLeft   = 2;
            this.GetRootVisualContainer().style.positionTop    = 22;
            this.GetRootVisualContainer().style.positionRight  = 2;
            this.GetRootVisualContainer().style.positionBottom = 2;
            this.GetRootVisualContainer().style.flexGrow       = 1;

            var windowResource = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(TemplatePath);

            if (windowResource != null)
            {
                root = windowResource.CloneTree(null);
                this.GetRootVisualContainer().Add(root);
                root.StretchToParentSize();

                Collection.SetFilter(PackageManagerPrefs.GetLastUsedPackageFilter(Directory.GetCurrentDirectory()));

                SetupPackageDetails();
                SetupPackageList();
                SetupSearchToolbar();
                SetupToolbar();
                SetupStatusbar();
                SetupCollection();

                // Disable filter while fetching first results
                if (!Collection.LatestListPackages.Any())
                {
                    PackageManagerToolbar.SetEnabled(false);
                }
                else
                {
                    PackageList.SelectLastSelection(Collection.SelectedPackage);
                }

                Collection.FetchListOfflineCache(Collection.listOperationOfflineOngoing);
                Collection.FetchListCache(Collection.listOperationOngoing);
                Collection.FetchSearchCache(Collection.searchOperationOngoing);

                if (!collectionWasNull)
                {
                    Collection.UpdatePackageCollection(true);
                }
            }
        }
예제 #2
0
        public void OnEnable()
        {
            var rootElement = GetRootElement();
            var path        = EditorGUIUtility.isProSkin ? DarkStylePath : LightStylePath;
            var styleSheet  = EditorGUIUtility.LoadRequired(path) as StyleSheet;

            rootElement.styleSheets.Add(styleSheet);

            var collectionWasNull = Collection == null;

            if (Collection == null)
            {
                Collection = new PackageCollection();
            }

            if (SearchFilter == null)
            {
                SearchFilter = new PackageSearchFilter();
            }

            if (SelectionManager == null)
            {
                SelectionManager = new SelectionManager();
            }

            var windowResource = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(TemplatePath);

            if (windowResource != null)
            {
                root = windowResource.CloneTree();
                rootElement.Add(root);
                root.StretchToParentSize();

                Cache = new VisualElementCache(root);

                SelectionManager.SetCollection(Collection);
                Collection.OnFilterChanged += filter => SetupSelection();
                Collection.SetFilter(PackageManagerPrefs.LastUsedPackageFilter);

                if (!collectionWasNull)
                {
                    Collection.UpdatePackageCollection(true);
                }

                SetupPackageDetails();
                SetupPackageList();
                SetupSearchToolbar();
                SetupToolbar();
                SetupStatusbar();
                SetupCollection();
                SetupSelection();

                // Disable filter while fetching first results
                if (!Collection.LatestListPackages.Any())
                {
                    PackageManagerToolbar.SetEnabled(false);
                }

                Collection.FetchListOfflineCache(!Collection.listOperationOfflineOngoing);
                Collection.FetchListCache(!Collection.listOperationOngoing);
                Collection.FetchSearchCache(!Collection.searchOperationOngoing);

                Collection.TriggerPackagesChanged();
            }
        }
예제 #3
0
        public void OnEnable()
        {
            var styleSheet = Resources.GetStyleSheet();

            rootVisualElement.styleSheets.Add(styleSheet);

            var collectionWasNull = Collection == null;

            if (Collection == null)
            {
                Collection = new PackageCollection();
            }

            if (SearchFilter == null)
            {
                SearchFilter = new PackageSearchFilter();
            }

            if (SelectionManager == null)
            {
                SelectionManager = new SelectionManager();
            }

            var windowResource = Resources.GetVisualTreeAsset("PackageManagerWindow.uxml");

            if (windowResource != null)
            {
                root = windowResource.CloneTree();
                rootVisualElement.Add(root);
                root.StretchToParentSize();

                Cache = new VisualElementCache(root);

                SelectionManager.SetCollection(Collection);
                Collection.OnFilterChanged += filter => SetupSelection();
                if (collectionWasNull)
                {
                    LastUsedPackageFilter = PackageManagerPrefs.LastUsedPackageFilter;
                }

                Collection.SetFilter(LastUsedPackageFilter);
                Collection.UpdatePackageCollection(true);

                SetupPackageDetails();
                SetupPackageList();
                SetupSearchToolbar();
                SetupToolbar();
                SetupStatusbar();
                SetupCollection();
                SetupSelection();

                // Disable filter while fetching first results
                if (!Collection.LatestListPackages.Any())
                {
                    PackageManagerToolbar.SetEnabled(false);
                }

                if (!EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    Collection.FetchListOfflineCache(true);
                    Collection.FetchListCache(collectionWasNull);
                    Collection.FetchSearchCache(collectionWasNull);
                }
                Collection.TriggerPackagesChanged();
            }
        }