Ejemplo n.º 1
0
        public override void Setup()
        {
            const float yBounds = 0.5f;

            // Initial bounds must be set before the base.Setup() is called
            minBounds = new Vector3(MinBounds.x, yBounds, 0.25f);
            m_CustomStartingBounds = new Vector3(MinBounds.x, yBounds, 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>())
            {
                this.ConnectInterfaces(mb);
            }

            var parent = m_WorkspaceUI.frontPanel.parent;

            m_LocatePlayerUI        = ObjectUtils.Instantiate(m_LocatePlayerPrefab, parent, false).transform;
            m_PlayerDirectionButton = m_LocatePlayerUI.GetChild(0);
            foreach (var mb in m_LocatePlayerUI.GetComponentsInChildren <MonoBehaviour>())
            {
                var button = mb as Button;
                if (button)
                {
                    button.onClick.AddListener(RecenterOnPlayer);
                }
            }

            m_PlayerDirectionArrow = ObjectUtils.Instantiate(m_PlayerDirectionArrowPrefab, parent, false).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_ZoomSliderMax);
            m_ZoomSliderUI.zoomSlider.minValue  = Mathf.Log10(k_ZoomSliderMin);
            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>())
            {
                this.ConnectInterfaces(mb);
            }

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

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

            // Propagate initial bounds
            OnBoundsChanged();
        }
Ejemplo n.º 2
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 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;

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

            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();
        }