Esempio n. 1
0
        private void DisplayPackagesCacheSetting()
        {
            packagesCacheDropdown.SetIcon("folder");
            var packagesCacheDropdownMenu = new DropdownMenu();

            packagesCacheDropdownMenu.AppendAction(k_OpenFolder, action =>
            {
                if (!string.IsNullOrWhiteSpace(packagesCachePath.text))
                {
                    m_ApplicationProxy.RevealInFinder(packagesCachePath.text);
                }
            }, action => DropdownMenuAction.Status.Normal, "openLocation");
            packagesCacheDropdownMenu.AppendAction(k_ChangeLocation, action =>
            {
                var path = m_ApplicationProxy.OpenFolderPanel("Select Packages Cache Location", packagesCachePath.text);
                if (!string.IsNullOrWhiteSpace(path) && string.CompareOrdinal(path, m_CurrentPackagesConfig.path) != 0)
                {
                    m_UpmCacheRootClient.SetCacheRoot(path);
                }
            }, action => m_CurrentPackagesConfig.source != ConfigSource.Environment ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled, "selectLocation");
            packagesCacheDropdownMenu.AppendAction(k_ResetToDefaultLocation, action =>
            {
                m_UpmCacheRootClient.ClearCacheRoot();
            }, action => m_CurrentPackagesConfig.source == ConfigSource.User ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled, "resetLocation");
            packagesCacheDropdown.menu = packagesCacheDropdownMenu;

            m_UpmCacheRootClient.onGetCacheRootOperationError    += OnPackagesGetCacheRootOperationError;
            m_UpmCacheRootClient.onGetCacheRootOperationResult   += OnPackagesGetCacheRootOperationResult;
            m_UpmCacheRootClient.onSetCacheRootOperationError    += OnPackagesSetCacheRootOperationError;
            m_UpmCacheRootClient.onSetCacheRootOperationResult   += OnPackagesSetCacheRootOperationResult;
            m_UpmCacheRootClient.onClearCacheRootOperationError  += OnPackagesClearCacheRootOperationError;
            m_UpmCacheRootClient.onClearCacheRootOperationResult += OnPackagesClearCacheRootOperationResult;

            if (!m_ApplicationProxy.isBatchMode && m_ApplicationProxy.isUpmRunning)
            {
                packagesCachePath.SetValueWithoutNotify(string.Empty);
                packagesCacheDropdown.SetEnabled(false);

                UIUtils.SetElementDisplay(packagesCacheErrorBox, false);

                m_UpmCacheRootClient.GetCacheRoot();
            }
            else
            {
                packagesCachePath.SetValueWithoutNotify(string.Empty);
                packagesCacheDropdown.SetEnabled(false);

                DisplayPackagesCacheErrorBox(HelpBoxMessageType.Error, L10n.Tr("Cannot get the Packages Cache location, UPM server is not running."));
            }
        }