Exemple #1
0
        public override Vector2 GetWindowSize()
        {
            float totalHeight = 0;

            // Anchor Update Button
            totalHeight += 40;

            if (UserPrefs.ShowSearchField)
            {
                totalHeight += RowHeight + 2;
            }

            // Filter mode row.
            if (UserPrefs.ShowFilterToolbar)
            {
                totalHeight += RowHeight + 2;
            }

            int itemCount = DataSource.CountValidItems(dataSource.filteredItems);

            totalHeight += RowHeight * itemCount;

            float   iconBeforeLabelWidth = 22;
            Vector2 windowSize           = new Vector2(iconBeforeLabelWidth + buttonAndIconsWidth, totalHeight);

            // Content refers to all item rows without the search field and is used by the scroll view.
            float yStartPosition = UserPrefs.ShowSearchField ? RowHeight + 2 : 0;

            // Filter mode row content size.
            if (UserPrefs.ShowFilterToolbar)
            {
                yStartPosition += RowHeight + 2;
            }

            Vector2 contentSize = new Vector2(windowSize.x, windowSize.y - yStartPosition);

            // Account for the offset by the search field and the border line at the top of the window.
            float contentYOffset = (UserPrefs.ShowSearchField ? RowHeight + 1 : 0) + 1;

            // Filter mode row offset.
            if (UserPrefs.ShowFilterToolbar)
            {
                contentYOffset += RowHeight + 1;
            }

            this.contentRect = new Rect(new Vector2(0, contentYOffset), contentSize);

            // The popup window has a 1px gray border that covers the top and bottom.
            // Make enough room for the content to fit perfectly within.
            totalHeight += 2;
            windowSize.y = totalHeight;

            int maxHeight = Mathf.Min(Screen.currentResolution.height, 700);

            if (totalHeight > maxHeight)
            {
                // Window is clamped and must show scroll bars for its content.
                windowSize.y = maxHeight;

                // Extra size to fit vertical scroll bar without clipping icons.
                windowSize.x += 14;
            }

            return(windowSize);
        }
Exemple #2
0
 public SelectionPopup(IList <GameObject> options)
 {
     this.dataSource     = new DataSource(options);
     this.iconCache      = new IconCache();
     this.outlineManager = new OutlineManager();
 }