Exemplo n.º 1
0
        /// <summary>
        /// returns the current visible top row of buttons
        /// </summary>
        private void UpdateTopRow()
        {
            if (_count == 0) //There are no buttons in the grid
            {
                return;
            }
            if (_count == 1)
            {
                VisibleTopRow = new List <IterableButton>(1);
                VisibleTopRow.Add(_rootButton);
                return;
            }
            IterableButton button = _rootButton;

            //traverse the left column starting from the top, break on first visible button
            for (int i = 0; i < LeftColumn.Count; i++)
            {
                button = LeftColumn[i];
                if (ButtonGridTools.CheckIfButtonOutofBoundsTop(_gridLayout, _groupScrollRect, ParentRectTransform,
                                                                button))
                {
                    break;
                }
            }
            if (button != null)
            {
                //traverse the row the button is in
                int index = button.RowIndex;
                for (int i = 0; i < Grid[index].Count; i++)
                {
                    VisibleTopRow.Add(Grid[index].Row[i]);
                }
            }
        }
Exemplo n.º 2
0
        private void UpdateBottomRow()
        {
            if (_count == 0) //There are no buttons in the grid
            {
                return;
            }
            if (_count == 1)
            {
                VisibleBottomRow = new List <IterableButton>(1);
                VisibleBottomRow.Add(_rootButton);
                return;
            }
            IterableButton button = _rootButton;

            //traverse the left column starting from the bottom, break on first visible button

            for (int i = LeftColumn.Count - 1; i >= 0; i--)
            {
                try
                {
                    button = LeftColumn[i];
                }
                catch (Exception)
                {
                    Debug.Log("da");
                }
                button = LeftColumn[i];
                if (ButtonGridTools.CheckIfButtonOutBoundsBottom(_gridLayout, _groupScrollRect, ParentRectTransform,
                                                                 button))
                {
                    break;
                }
            }
            if (button != null)
            {
                //traverse the row the button is in
                int index = button.RowIndex;
                for (int i = 0; i < Grid[index].Count; i++)
                {
                    Debug.Log(i);
                    VisibleBottomRow.Add(Grid[index].Row[i]);
                }
            }
        }
Exemplo n.º 3
0
        void LateUpdate()
        {
            if (_debug)
            {
                Debug.Log("startit");
            }
            //check what the current selected game object is
            GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;

            //get the iterable button
            if (currentSelectedGameObject != null)
            {
                IterableButton currentButton = currentSelectedGameObject.GetComponent <IterableButton>();
                //check if this button has changed since the last frame
                if (currentButton != null && currentButton == _previousButton && !_isRepositioningParent)
                {
                    if (ButtonGridTools.CheckIfButtonOutofBoundsTop(_gridLayoutGroup, _scrollRect, _parentRectTransform, currentButton))
                    {
                        _isRepositioningParent = true;
                        Debug.Log("here1");
                        StartCoroutine(RepositionParent(currentButton.RectTransform.position));
                    }
                    else if (ButtonGridTools.CheckIfButtonOutBoundsBottom(_gridLayoutGroup, _scrollRect, _parentRectTransform, currentButton))
                    {
                        _isRepositioningParent = true;
                        Debug.Log("here");
                        StartCoroutine(RepositionParent(currentButton.RectTransform.position));
                    }
                }
                _previousButton = currentButton;
            }
            if (currentSelectedGameObject == null)
            {
                _previousButton = null;
            }


            //check if current button is visible
        }