public static void InitInstance(ref PackageCollection value)
        {
            if (value == null)  // UI window opened
            {
                value = instance;

                Instance.OnPackagesChanged = delegate { };
                Instance.OnFilterChanged   = delegate { };
                Instance.SearchSignal.ResetEvents();
                Instance.ListSignal.ResetEvents();

                Instance.FetchListOfflineCache(true);
                Instance.FetchListCache(true);
                Instance.FetchSearchCache(true);
            }
            else // Domain reload
            {
                instance = value;

                Instance.RebuildPackageDictionary();

                // Resume operations interrupted by domain reload
                Instance.FetchListOfflineCache(Instance.listOperationOfflineOngoing);
                Instance.FetchListCache(Instance.listOperationOngoing);
                Instance.FetchSearchCache(Instance.searchOperationOngoing);
            }
        }
示例#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);
                }
            }
        }
        public void Setup(PackageCollection collection)
        {
            LastUpdateTime = collection.lastUpdateTime;
            UpdateStatusMessage();

            StatusLabel.RegisterCallback <MouseDownEvent>(e =>
            {
                collection.FetchListOfflineCache(true);
                collection.FetchListCache(true);
                collection.FetchSearchCache(true);
            });
        }
        public void Setup(PackageCollection collection)
        {
            LastUpdateTime = collection.lastUpdateTime;
            UpdateStatusMessage();

            StatusLabel.RegisterCallback <MouseDownEvent>(e =>
            {
                // only react to left mouse button
                if (e.button != 0)
                {
                    return;
                }
                if (!EditorApplication.isPlaying)
                {
                    collection.FetchListOfflineCache(true);
                    collection.FetchListCache(true);
                    collection.FetchSearchCache(true);
                }
            });
        }
示例#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();
            }
        }