Exemplo n.º 1
0
        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 contentPrefab = ObjectUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false);

            m_HierarchyUI = contentPrefab.GetComponent <HierarchyUI>();
            m_HierarchyUI.listView.lockedQueryString = k_LockedQuery;
            hierarchyData = m_HierarchyData;

            if (m_FilterPrefab)
            {
                m_FilterUI = ObjectUtils.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 = ObjectUtils.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 = ObjectUtils.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.dragStarted  += OnScrollDragStarted;
            scrollHandle.dragging     += OnScrollDragging;
            scrollHandle.dragEnded    += OnScrollDragEnded;
            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();
        }
Exemplo n.º 2
0
        public override void Setup()
        {
            // Initial bounds must be set before the base.Setup() is called
            minBounds = new Vector3(0.375f, k_MinBounds.y, 0.5f);
            m_CustomStartingBounds = minBounds;

            base.Setup();

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

            m_HierarchyUI = contentPrefab.GetComponent <HierarchyUI>();
            hierarchyData = m_HierarchyData;

            m_FilterUI = ObjectUtils.Instantiate(m_FilterPrefab, m_WorkspaceUI.frontPanel, false).GetComponent <FilterUI>();
            foreach (var mb in m_FilterUI.GetComponentsInChildren <MonoBehaviour>())
            {
                connectInterfaces(mb);
            }
            m_FilterUI.filterList = m_FilterList;

            var focusUI = ObjectUtils.Instantiate(m_FocusPrefab, m_WorkspaceUI.frontPanel, false);

            foreach (var mb in focusUI.GetComponentsInChildren <MonoBehaviour>())
            {
                connectInterfaces(mb);
            }
            focusUI.GetComponentInChildren <Button>(true).onClick.AddListener(FocusSelection);

            var createEmptyUI = ObjectUtils.Instantiate(m_CreateEmptyPrefab, m_WorkspaceUI.frontPanel, false);

            foreach (var mb in createEmptyUI.GetComponentsInChildren <MonoBehaviour>())
            {
                connectInterfaces(mb);
            }
            createEmptyUI.GetComponentInChildren <Button>(true).onClick.AddListener(CreateEmptyGameObject);

            var hierarchyListView = m_HierarchyUI.listView;

            hierarchyListView.selectRow = SelectRow;

            var handle = m_HierarchyUI.scrollHandle;

            // 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
            handle.dragStarted  += OnScrollPanelDragHighlightBegin;
            handle.dragEnded    += OnScrollPanelDragHighlightEnd;
            handle.hoverStarted += OnScrollPanelHoverHighlightBegin;
            handle.hoverEnded   += OnScrollPanelHoverHighlightEnd;

            // Assign highlight references
            m_HighlightContainer = m_HierarchyUI.highlight.transform.parent.transform;

            // Propagate initial bounds
            OnBoundsChanged();
        }