Пример #1
0
        public override void Setup()
        {
            // Initial bounds must be set before the base.Setup() is called
            minBounds = k_MinBounds;
            m_CustomStartingBounds = minBounds;

            base.Setup();

            var contentPrefab = ObjectUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false);

            m_PolyUI = contentPrefab.GetComponent <PolyUI>();

            var gridView = m_PolyUI.gridView;

            this.ConnectInterfaces(gridView);
            assetData = new List <PolyGridAsset>();

            var sliderObject = ObjectUtils.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);
            }

            SetupCategoryFilterUI();
            SetupComplextyFilterUI();
            SetupFormatFilterUI();
            SetupSortingUI();

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

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

            var scrollHandle          = m_PolyUI.scrollHandle;
            var scrollHandleTransform = scrollHandle.transform;

            scrollHandleTransform.SetParent(m_WorkspaceUI.topFaceContainer);
            scrollHandleTransform.localScale    = k_ScrollHandleScale;
            scrollHandleTransform.localPosition = k_ScrollHandlePosition;

            scrollHandle.dragStarted           += OnScrollDragStarted;
            scrollHandle.dragging              += OnScrollDragging;
            scrollHandle.dragEnded             += OnScrollDragEnded;
            m_PolyUI.scrollHandle.hoverStarted += OnScrollHoverStarted;
            m_PolyUI.scrollHandle.hoverEnded   += OnScrollHoverEnded;

            // Propagate initial bounds
            OnBoundsChanged();
        }
Пример #2
0
        public override void Setup()
        {
            // Initial bounds must be set before the base.Setup() is called
            minBounds = new Vector3(MinBounds.x, MinBounds.y, 0.5f);
            m_CustomStartingBounds = new Vector3(0.8f, 0.4f, 0.5f);

            base.Setup();

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

            var contentPrefab = ObjectUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false);

            m_ProjectUI = contentPrefab.GetComponent <ProjectUI>();

            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 = ObjectUtils.Instantiate(m_FilterPrefab, m_WorkspaceUI.frontPanel, false).GetComponent <FilterUI>();
            foreach (var mb in m_FilterUI.GetComponentsInChildren <MonoBehaviour>())
            {
                this.ConnectInterfaces(mb);
            }
            filterList = m_FilterList;

            var sliderObject = ObjectUtils.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);
            }

            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.dragStarted += OnScrollDragStarted;
                handle.dragging    += OnScrollDragging;
                handle.dragEnded   += OnScrollDragEnded;
            }

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

            // Propagate initial bounds
            OnBoundsChanged();
        }
Пример #3
0
        public override void Setup()
        {
            // Initial bounds must be set before the base.Setup() is called
            minBounds = new Vector3(k_MinBounds.x, k_MinBounds.y, 0.25f);
            m_CustomStartingBounds = new Vector3(k_MinBounds.x, k_MinBounds.y, 0.5f);

            base.Setup();

            ObjectUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false);
            m_MiniWorldUI  = GetComponentInChildren <MiniWorldUI>();
            m_GridMaterial = MaterialUtils.GetMaterialClone(m_MiniWorldUI.grid);

            var resetUI = ObjectUtils.Instantiate(m_RecenterUIPrefab, m_WorkspaceUI.frontPanel, false).GetComponentInChildren <ResetUI>();

            resetUI.resetButton.onClick.AddListener(ResetChessboard);
            foreach (var mb in resetUI.GetComponentsInChildren <MonoBehaviour>())
            {
                connectInterfaces(mb);
            }

            var parent         = m_WorkspaceUI.frontPanel.parent;
            var locatePlayerUI = ObjectUtils.Instantiate(m_LocatePlayerPrefab, parent, false);

            m_PlayerDirectionButton = locatePlayerUI.transform.GetChild(0);
            foreach (var mb in locatePlayerUI.GetComponentsInChildren <MonoBehaviour>())
            {
                var button = mb as Button;
                if (button)
                {
                    button.onClick.AddListener(RecenterOnPlayer);
                }
            }

            var arrow = ObjectUtils.Instantiate(m_PlayerDirectionArrowPrefab, parent, false);

            arrow.transform.localPosition = new Vector3(-0.232f, 0.03149995f, 0f);
            m_PlayerDirectionArrow        = arrow.transform;

            // Set up MiniWorld
            m_MiniWorld = GetComponentInChildren <MiniWorld>();
            m_MiniWorld.referenceTransform.position   = Vector3.up * k_InitReferenceYOffset * k_InitReferenceScale;
            m_MiniWorld.referenceTransform.localScale = Vector3.one * k_InitReferenceScale;

            // Set up Zoom Slider
            var sliderObject = ObjectUtils.Instantiate(m_ZoomSliderPrefab, m_WorkspaceUI.frontPanel, false);

            m_ZoomSliderUI                      = sliderObject.GetComponentInChildren <ZoomSliderUI>();
            m_ZoomSliderUI.sliding             += OnSliding;
            m_ZoomSliderUI.zoomSlider.maxValue  = Mathf.Log10(k_MaxZoomScale);
            m_ZoomSliderUI.zoomSlider.minValue  = Mathf.Log10(k_MinZoomScale);
            m_ZoomSliderUI.zoomSlider.direction = Slider.Direction.RightToLeft;             // Invert direction for expected ux; zoom in as slider moves left to right
            m_ZoomSliderUI.zoomSlider.value     = Mathf.Log10(k_InitReferenceScale);
            foreach (var mb in m_ZoomSliderUI.GetComponentsInChildren <MonoBehaviour>())
            {
                connectInterfaces(mb);
            }

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

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

            var frontHandle = m_WorkspaceUI.directManipulator.GetComponent <BaseHandle>();

            frontHandle.dragStarted += DragStarted;
            frontHandle.dragEnded   += DragEnded;

            // Propagate initial bounds
            OnBoundsChanged();
        }