コード例 #1
0
        private void InitializeButtons()
        {
            m_DisableIfCompiling = new ButtonDisableCondition(() => m_Application.isCompiling,
                                                              L10n.Tr("You need to wait until the compilation is finished to perform this action."));
            m_DisableIfInstallOrUninstallInProgress = new ButtonDisableCondition(() => m_PackageDatabase.isInstallOrUninstallInProgress,
                                                                                 L10n.Tr("You need to wait until other install or uninstall operations are finished to perform this action."));
            m_DisableIfNoNetwork = new ButtonDisableCondition(() => !m_Application.isInternetReachable,
                                                              L10n.Tr("You need to restore your network connection to perform this action."));

            m_UnlockButton           = new PackageUnlockButton(m_PageManager);
            m_UnlockButton.onAction += RefreshBuiltInButtons;
            m_BuiltInActions.Add(m_UnlockButton.element);

            m_AddButton = new PackageAddButton(m_Application, m_PackageDatabase);
            m_AddButton.SetGlobalDisableConditions(m_DisableIfInstallOrUninstallInProgress, m_DisableIfCompiling);
            m_AddButton.onAction += RefreshBuiltInButtons;
            m_BuiltInActions.Add(m_AddButton.element);

            m_UpdateButton = new PackageUpdateButton(m_Application, m_PackageDatabase, m_PageManager);
            m_UpdateButton.SetGlobalDisableConditions(m_DisableIfInstallOrUninstallInProgress, m_DisableIfCompiling);
            m_UpdateButton.onAction += RefreshBuiltInButtons;
            m_BuiltInActions.Add(m_UpdateButton.element);

            m_GitUpdateButton = new PackageGitUpdateButton(m_PackageDatabase);
            m_GitUpdateButton.SetGlobalDisableConditions(m_DisableIfInstallOrUninstallInProgress, m_DisableIfCompiling);
            m_GitUpdateButton.onAction += RefreshBuiltInButtons;
            m_BuiltInActions.Add(m_GitUpdateButton.element);

            m_RemoveButton = new PackageRemoveButton(m_Application, m_PackageManagerPrefs, m_PackageDatabase, m_PageManager);
            m_RemoveButton.SetGlobalDisableConditions(m_DisableIfInstallOrUninstallInProgress, m_DisableIfCompiling);
            m_RemoveButton.onAction += RefreshBuiltInButtons;
            m_BuiltInActions.Add(m_RemoveButton.element);

            m_RemoveCustomButton = new PackageRemoveCustomButton(m_Application, m_PackageDatabase, m_PageManager);
            m_RemoveCustomButton.SetGlobalDisableConditions(m_DisableIfInstallOrUninstallInProgress, m_DisableIfCompiling);
            m_RemoveCustomButton.onAction += RefreshBuiltInButtons;
            m_BuiltInActions.Add(m_RemoveCustomButton.element);

            m_ResetButton = new PackageResetButton(m_Application, m_PackageDatabase, m_PageManager);
            m_ResetButton.SetGlobalDisableConditions(m_DisableIfInstallOrUninstallInProgress, m_DisableIfCompiling);
            m_ResetButton.onAction += RefreshBuiltInButtons;
            m_ResetButton.element.SetIcon("customizedIcon");
            m_BuiltInActions.Add(m_ResetButton.element);

            m_ImportButton = new PackageImportButton(m_AssetStoreDownloadManager, m_PackageDatabase);
            m_ImportButton.SetGlobalDisableConditions(m_DisableIfCompiling);
            m_ImportButton.onAction += RefreshBuiltInButtons;
            m_BuiltInActions.Add(m_ImportButton.element);

            m_RedownloadButton = new PackageRedownloadButton(m_AssetStoreDownloadManager, m_AssetStoreCache, m_PackageDatabase);
            m_RedownloadButton.SetGlobalDisableConditions(m_DisableIfCompiling);
            m_RedownloadButton.onAction += RefreshBuiltInButtons;
            m_BuiltInActions.Add(m_RedownloadButton.element);

            m_DownloadButton = new PackageDownloadButton(m_AssetStoreDownloadManager, m_AssetStoreCache, m_PackageDatabase);
            m_DownloadButton.SetGlobalDisableConditions(m_DisableIfNoNetwork, m_DisableIfCompiling);
            m_DownloadButton.onAction += Refresh;
            m_BuiltInActions.Add(m_DownloadButton.element);

            m_DownloadUpdateButton = new PackageDownloadUpdateButton(m_AssetStoreDownloadManager, m_AssetStoreCache, m_PackageDatabase);
            m_DownloadUpdateButton.SetGlobalDisableConditions(m_DisableIfNoNetwork, m_DisableIfCompiling);
            m_DownloadUpdateButton.onAction += Refresh;
            m_BuiltInActions.Add(m_DownloadUpdateButton.element);

            m_DowngradeButton = new PackageDowngradeButton(m_AssetStoreDownloadManager, m_AssetStoreCache, m_PackageDatabase);
            m_DowngradeButton.SetGlobalDisableConditions(m_DisableIfNoNetwork, m_DisableIfCompiling);
            m_DowngradeButton.onAction += Refresh;
            m_BuiltInActions.Add(m_DowngradeButton.element);

            m_SignInButton = new PackageSignInButton(m_UnityConnectProxy);
            m_SignInButton.SetGlobalDisableConditions(m_DisableIfNoNetwork);
            m_SignInButton.onAction += RefreshBuiltInButtons;
            m_BuiltInActions.Add(m_SignInButton.element);

            // Since pause, resume, cancel buttons are only used to control the download progress, we want to put them in the progress container instead
            m_CancelButton = new PackageCancelDownloadButton(m_AssetStoreDownloadManager, m_PackageDatabase);
            m_CancelButton.SetGlobalDisableConditions(m_DisableIfCompiling);
            m_CancelButton.onAction += Refresh;
            m_ProgressContainer.Add(m_CancelButton.element);

            m_PauseButton = new PackagePauseDownloadButton(m_AssetStoreDownloadManager, m_PackageDatabase);
            m_PauseButton.SetGlobalDisableConditions(m_DisableIfCompiling);
            m_PauseButton.onAction += RefreshProgressControlButtons;
            m_ProgressContainer.Add(m_PauseButton.element);

            m_ResumeButton = new PackageResumeDownloadButton(m_AssetStoreDownloadManager, m_PackageDatabase);
            m_ResumeButton.SetGlobalDisableConditions(m_DisableIfNoNetwork, m_DisableIfCompiling);
            m_ResumeButton.onAction += RefreshProgressControlButtons;
            m_ProgressContainer.Add(m_ResumeButton.element);
        }
コード例 #2
0
        public override void Refresh(IPackageVersion version)
        {
            m_Version = version;
            if (m_Version?.uniqueId != m_PackageManagerPrefs.packageDisplayedInVersionHistoryTab)
            {
                m_PackageManagerPrefs.ClearExpandedVersionHistoryItems();
                m_PackageManagerPrefs.packageDisplayedInVersionHistoryTab = m_Version?.uniqueId;
            }

            foreach (var historyItem in m_VersionHistoryList.Children().OfType <PackageDetailsVersionHistoryItem>())
            {
                historyItem.StopSpinner();
            }
            m_VersionHistoryList.Clear();

            if (m_Version?.package?.versions == null)
            {
                UIUtils.SetElementDisplay(m_Container, false);
                return;
            }

            var seeAllVersions = m_PageManager.GetVisualState(m_Version.package)?.seeAllVersions ?? false;
            var keyVersions    = m_Version.package.versions.key.ToList();
            var allVersions    = m_Version.package.versions.ToList();

            var versions = seeAllVersions ? allVersions : keyVersions;

            versions.Reverse();

            var seeVersionsToolbar = !seeAllVersions && allVersions.Count > keyVersions.Count && (m_Version.package.Is(PackageType.ScopedRegistry) || m_SettingsProxy.seeAllPackageVersions || m_Version.package.versions.installed?.HasTag(PackageTag.Experimental) == true);

            UIUtils.SetElementDisplay(m_VersionsToolbar, seeVersionsToolbar);

            var latestVersion           = m_Version.package?.versions.latest;
            var primaryVersion          = m_Version.package?.versions.primary;
            var multipleVersionsVisible = versions.Count > 1;

            foreach (var v in versions)
            {
                PackageToolBarRegularButton button;
                if (primaryVersion?.isInstalled ?? false)
                {
                    if (v == primaryVersion)
                    {
                        button = new PackageRemoveButton(m_ApplicationProxy, m_PackageManagerPrefs, m_PackageDatabase, m_PageManager);
                        button.SetGlobalDisableConditions(m_DisableIfCompiling, m_DisableIfInstallOrUninstallInProgress);
                    }
                    else
                    {
                        button = new PackageUpdateButton(m_ApplicationProxy, m_PackageDatabase, m_PageManager, false);
                        button.SetGlobalDisableConditions(m_DisableIfCompiling, m_DisableIfInstallOrUninstallInProgress);
                    }
                }
                else
                {
                    button = new PackageAddButton(m_ApplicationProxy, m_PackageDatabase);
                    button.SetGlobalDisableConditions(m_DisableIfCompiling, m_DisableIfInstallOrUninstallInProgress);
                }

                var isExpanded         = m_PackageManagerPrefs.IsVersionHistoryItemExpanded(v.uniqueId);
                var isLatest           = v == latestVersion;
                var versionHistoryItem = new PackageDetailsVersionHistoryItem(m_ResourceLoader,
                                                                              m_PackageDatabase,
                                                                              m_UpmCache,
                                                                              m_ApplicationProxy,
                                                                              m_IOProxy,
                                                                              v,
                                                                              multipleVersionsVisible,
                                                                              isLatest,
                                                                              isExpanded,
                                                                              button);
                versionHistoryItem.onToggleChanged += expanded => m_PackageManagerPrefs.SetVersionHistoryItemExpanded(versionHistoryItem.version?.uniqueId, expanded);

                m_VersionHistoryList.Add(versionHistoryItem);
            }

            UIUtils.SetElementDisplay(m_Container, true);
        }