示例#1
0
        void SetupCategoryFilterUI()
        {
            m_CategoryFilterUI = EditorXRUtils.Instantiate(m_FilterUIPrefab, m_WorkspaceUI.frontPanel, false).GetComponent <FilterUI>();
            m_CategoryFilterUI.transform.localPosition += Vector3.right * k_FilterUIWidth * 3;
            foreach (var mb in m_CategoryFilterUI.GetComponentsInChildren <MonoBehaviour>())
            {
                this.ConnectInterfaces(mb);
            }

            m_CategoryFilterUI.filterChanged += () =>
            {
                var gridView    = m_PolyUI.gridView;
                var searchQuery = m_CategoryFilterUI.searchQuery;
                if (string.IsNullOrEmpty(searchQuery))
                {
                    gridView.category = PolyCategory.UNSPECIFIED;
                }
                else
                {
                    gridView.category = (PolyCategory)Enum.Parse(typeof(PolyCategory), searchQuery.ToUpper());
                }

                gridView.RequestAssetList();
                UpdateComplexityFilterUI();
            };

            m_CategoryFilterUI.buttonClicked += handle =>
            {
                m_SortingUI.SetListVisibility(false);
                m_FormatFilterUI.SetListVisibility(false);
                m_ComplexityFilterUI.SetListVisibility(false);
            };

            var categoryList = new List <string>();
            var textInfo     = Thread.CurrentThread.CurrentCulture.TextInfo;

            foreach (var category in Enum.GetNames(typeof(PolyCategory)))
            {
                if (category == "UNSPECIFIED")
                {
                    continue;
                }

                categoryList.Add(textInfo.ToTitleCase(category.ToLower()));
            }

            m_CategoryFilterUI.filterList = categoryList;

            m_CategoryFilterUI.GetComponentInChildren <Tooltip>().tooltipText = "Filter by Category";

            UpdateCategoryFilterUI();
        }
示例#2
0
        void SetupFormatFilterUI()
        {
            m_FormatFilterUI = EditorXRUtils.Instantiate(m_FilterUIPrefab, m_WorkspaceUI.frontPanel, false).GetComponent <FilterUI>();
            m_FormatFilterUI.transform.localPosition += Vector3.right * k_FilterUIWidth;
            foreach (var mb in m_FormatFilterUI.GetComponentsInChildren <MonoBehaviour>())
            {
                this.ConnectInterfaces(mb);
            }

            m_FormatFilterUI.filterChanged += () =>
            {
                var gridView = m_PolyUI.gridView;
                switch (m_FormatFilterUI.searchQuery)
                {
                case k_Blocks:
                    gridView.format = PolyFormatFilter.BLOCKS;
                    break;

                case k_TiltBrush:
                    gridView.format = PolyFormatFilter.TILT;
                    break;

                default:
                    gridView.format = null;
                    break;
                }

                gridView.RequestAssetList();
                UpdateFormatFilterUI();
            };

            m_FormatFilterUI.buttonClicked += handle =>
            {
                m_SortingUI.SetListVisibility(false);
                m_ComplexityFilterUI.SetListVisibility(false);
                m_CategoryFilterUI.SetListVisibility(false);
            };

            m_FormatFilterUI.filterList = new List <string>
            {
                k_Blocks,
                k_TiltBrush
            };

            m_FormatFilterUI.GetComponentInChildren <Tooltip>().tooltipText = "Filter by Format";

            UpdateFormatFilterUI();
        }
示例#3
0
        void SetupComplextyFilterUI()
        {
            m_ComplexityFilterUI = EditorXRUtils.Instantiate(m_FilterUIPrefab, m_WorkspaceUI.frontPanel, false).GetComponent <FilterUI>();
            m_ComplexityFilterUI.transform.localPosition += Vector3.right * k_FilterUIWidth * 2;
            foreach (var mb in m_ComplexityFilterUI.GetComponentsInChildren <MonoBehaviour>())
            {
                this.ConnectInterfaces(mb);
            }

            m_ComplexityFilterUI.filterChanged += () =>
            {
                var gridView = m_PolyUI.gridView;
                switch (m_ComplexityFilterUI.searchQuery)
                {
                case k_Medium:
                    gridView.complexity = PolyMaxComplexityFilter.MEDIUM;
                    break;

                case k_Simple:
                    gridView.complexity = PolyMaxComplexityFilter.SIMPLE;
                    break;

                default:
                    gridView.complexity = PolyMaxComplexityFilter.UNSPECIFIED;
                    break;
                }

                gridView.RequestAssetList();
                UpdateComplexityFilterUI();
            };

            m_ComplexityFilterUI.buttonClicked += handle =>
            {
                m_SortingUI.SetListVisibility(false);
                m_FormatFilterUI.SetListVisibility(false);
                m_CategoryFilterUI.SetListVisibility(false);
            };

            m_ComplexityFilterUI.filterList = new List <string>
            {
                k_Medium,
                k_Simple
            };

            m_ComplexityFilterUI.GetComponentInChildren <Tooltip>().tooltipText = "Filter by Complexity";

            UpdateComplexityFilterUI();
        }
示例#4
0
        void SetupSortingUI()
        {
            m_SortingUI = EditorXRUtils.Instantiate(m_FilterUIPrefab, m_WorkspaceUI.frontPanel, false).GetComponent <FilterUI>();
            foreach (var mb in m_SortingUI.GetComponentsInChildren <MonoBehaviour>())
            {
                this.ConnectInterfaces(mb);
            }

            m_SortingUI.filterChanged += () =>
            {
                var gridView = m_PolyUI.gridView;
                switch (m_SortingUI.searchQuery)
                {
                case k_Featured:
                    gridView.sorting = PolyOrderBy.BEST;
                    break;

                case k_Newest:
                    gridView.sorting = PolyOrderBy.NEWEST;
                    break;
                }

                gridView.RequestAssetList();
                UpdateSortingUI();
            };

            m_SortingUI.buttonClicked += handle =>
            {
                m_FormatFilterUI.SetListVisibility(false);
                m_ComplexityFilterUI.SetListVisibility(false);
                m_CategoryFilterUI.SetListVisibility(false);
            };

            m_SortingUI.addDefaultOption = false;
            m_SortingUI.filterList       = new List <string>
            {
                k_Featured,
                k_Newest
            };

            m_SortingUI.GetComponentInChildren <Tooltip>().tooltipText = "Change sorting";

            UpdateSortingUI();
        }
示例#5
0
        public override void Setup()
        {
            // Initial bounds must be set before the base.Setup() is called
            minBounds = k_MinBounds;
            m_CustomStartingBounds = k_CustomStartingBounds;

            base.Setup();

            topPanelDividerOffset = k_LeftPaneRatio; // enable & position the top-divider(mask) slightly to the left of workspace center

            var content = EditorXRUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false);

            m_ProjectUI = content.GetComponent <ProjectUI>();
            foreach (var behavior in content.GetComponentsInChildren <MonoBehaviour>(true))
            {
                this.InjectFunctionalitySingle(behavior);
            }

            var assetGridView = m_ProjectUI.assetGridView;

            this.ConnectInterfaces(assetGridView);
            assetGridView.matchesFilter = this.MatchesFilter;
            assetGridView.data          = new List <AssetData>();

            var folderListView = m_ProjectUI.folderListView;

            this.ConnectInterfaces(folderListView);
            folderListView.folderSelected += OnFolderSelected;
            folderData = m_FolderData;

            m_FilterUI = EditorXRUtils.Instantiate(m_FilterPrefab, m_WorkspaceUI.frontPanel, false).GetComponent <FilterUI>();
            foreach (var mb in m_FilterUI.GetComponentsInChildren <MonoBehaviour>())
            {
                this.ConnectInterfaces(mb);
                this.InjectFunctionalitySingle(mb);
            }

            filterList = m_FilterList;

            foreach (var button in m_FilterUI.GetComponentsInChildren <WorkspaceButton>())
            {
                button.clicked += OnButtonClicked;
                button.hovered += OnButtonHovered;
            }

            var sliderObject = EditorXRUtils.Instantiate(m_SliderPrefab, m_WorkspaceUI.frontPanel, false);

            m_ZoomSliderUI = sliderObject.GetComponent <ZoomSliderUI>();
            m_ZoomSliderUI.zoomSlider.minValue = Mathf.Log10(k_MinScale);
            m_ZoomSliderUI.zoomSlider.maxValue = Mathf.Log10(k_MaxScale);
            m_ZoomSliderUI.sliding            += Scale;
            UpdateZoomSliderValue();
            foreach (var mb in m_ZoomSliderUI.GetComponentsInChildren <MonoBehaviour>())
            {
                this.ConnectInterfaces(mb);
                this.InjectFunctionalitySingle(mb);
            }

            var zoomTooltip = sliderObject.GetComponentInChildren <Tooltip>();

            if (zoomTooltip)
            {
                zoomTooltip.tooltipText = "Drag the Handle to Zoom the Asset Grid";
            }

            var scrollHandles = new[]
            {
                m_ProjectUI.folderScrollHandle,
                m_ProjectUI.assetScrollHandle
            };

            foreach (var handle in scrollHandles)
            {
                // Scroll Handle shouldn't move on bounds change
                handle.transform.parent = m_WorkspaceUI.sceneContainer;

                handle.pointerDown += OnScrollPointerDown;
                handle.dragging    += OnScrollDragging;
                handle.pointerUp   += OnScrollPointerUp;
            }

            // Hookup highlighting calls
            m_ProjectUI.assetScrollHandle.pointerDown   += OnAssetGridDragHighlightBegin;
            m_ProjectUI.assetScrollHandle.pointerUp     += OnAssetGridDragHighlightEnd;
            m_ProjectUI.assetScrollHandle.hoverStarted  += OnAssetGridHoverHighlightBegin;
            m_ProjectUI.assetScrollHandle.hoverEnded    += OnAssetGridHoverHighlightEnd;
            m_ProjectUI.folderScrollHandle.pointerDown  += OnFolderPanelDragHighlightBegin;
            m_ProjectUI.folderScrollHandle.pointerUp    += OnFolderPanelDragHighlightEnd;
            m_ProjectUI.folderScrollHandle.hoverStarted += OnFolderPanelHoverHighlightBegin;
            m_ProjectUI.folderScrollHandle.hoverEnded   += OnFolderPanelHoverHighlightEnd;

            // Propagate initial bounds
            OnBoundsChanged();
        }
        public override void Setup()
        {
            // Initial bounds must be set before the base.Setup() is called
            minBounds = new Vector3(0.522f, MinBounds.y, 0.5f);
            m_CustomStartingBounds = minBounds;

            base.Setup();

            var content = EditorXRUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false);

            m_HierarchyUI = content.GetComponent <HierarchyUI>();
            m_HierarchyUI.listView.lockedQueryString = k_Locked;
            hierarchyData = m_HierarchyData;
            foreach (var behavior in content.GetComponentsInChildren <MonoBehaviour>(true))
            {
                this.InjectFunctionalitySingle(behavior);
            }

            if (m_FilterPrefab)
            {
                m_FilterUI = EditorXRUtils.Instantiate(m_FilterPrefab, m_WorkspaceUI.frontPanel, false).GetComponent <FilterUI>();
                foreach (var mb in m_FilterUI.GetComponentsInChildren <MonoBehaviour>())
                {
                    this.ConnectInterfaces(mb);
                }

                m_FilterUI.filterList = m_FilterList;
            }

            if (m_FocusPrefab)
            {
                var focusUI = EditorXRUtils.Instantiate(m_FocusPrefab, m_WorkspaceUI.frontPanel, false);
                foreach (var mb in focusUI.GetComponentsInChildren <MonoBehaviour>())
                {
                    this.ConnectInterfaces(mb);
                }
                var button = focusUI.GetComponentInChildren <WorkspaceButton>(true);
                button.clicked += FocusSelection;
                button.hovered += OnButtonHovered;
            }

            if (m_CreateEmptyPrefab)
            {
                var createEmptyUI = EditorXRUtils.Instantiate(m_CreateEmptyPrefab, m_WorkspaceUI.frontPanel, false);
                foreach (var mb in createEmptyUI.GetComponentsInChildren <MonoBehaviour>())
                {
                    this.ConnectInterfaces(mb);
                }
                var button = createEmptyUI.GetComponentInChildren <WorkspaceButton>(true);
                button.clicked += CreateEmptyGameObject;
                button.clicked += OnButtonClicked;
                button.hovered += OnButtonHovered;
            }

            var listView = m_HierarchyUI.listView;

            listView.selectRow      = SelectRow;
            listView.matchesFilter  = this.MatchesFilter;
            listView.getSearchQuery = () => searchQuery;
            this.ConnectInterfaces(listView);

            var scrollHandle = m_HierarchyUI.scrollHandle;

            scrollHandle.pointerDown  += OnScrollPointerDown;
            scrollHandle.dragging     += OnScrollDragging;
            scrollHandle.pointerUp    += OnScrollPointerUp;
            scrollHandle.hoverStarted += OnScrollHoverStarted;
            scrollHandle.hoverEnded   += OnScrollHoverEnded;

            contentBounds = new Bounds(Vector3.zero, m_CustomStartingBounds.Value);

            var scrollHandleTransform = m_HierarchyUI.scrollHandle.transform;

            scrollHandleTransform.SetParent(m_WorkspaceUI.topFaceContainer);
            scrollHandleTransform.localScale    = new Vector3(1.03f, 0.02f, 1.02f); // Extra space for scrolling
            scrollHandleTransform.localPosition = new Vector3(0f, -0.015f, 0f);     // Offset from content for collision purposes

            m_FilterUI.buttonClicked += OnButtonClicked;
            m_FilterUI.buttonHovered += OnButtonHovered;

            // Propagate initial bounds
            OnBoundsChanged();
        }