示例#1
0
        public void OnEnable()
        {
            PackageCollection.InitInstance(ref Collection);
            PackageSearchFilter.InitInstance(ref SearchFilter);

            this.GetRootVisualContainer().AddStyleSheetPath(EditorGUIUtility.isProSkin ? DarkStylePath : LightStylePath);

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

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

                PackageList.OnSelected    += OnPackageSelected;
                PackageList.OnLoaded      += OnPackagesLoaded;
                PackageList.OnFocusChange += OnListFocusChange;

                PackageManagerToolbar.SearchToolbar.OnSearchChange += OnSearchChange;
                PackageManagerToolbar.SearchToolbar.OnFocusChange  += OnToolbarFocusChange;

                // Disable filter while fetching first results
                if (!PackageCollection.Instance.LatestListPackages.Any())
                {
                    PackageManagerToolbar.SetEnabled(false);
                }
                else
                {
                    PackageList.SelectLastSelection();
                }
            }
        }
示例#2
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);
                }
            }
        }
示例#3
0
 public static void InitInstance(ref PackageSearchFilter value)
 {
     if (value == null)  // UI window opened
     {
         value = instance;
     }
     else // Domain reload
     {
         instance = value;
     }
 }
示例#4
0
 public void SetSearchFilter(PackageSearchFilter filter)
 {
     searchFilter = filter;
 }
示例#5
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();
            }
        }
示例#6
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();
            }
        }