Esempio n. 1
0
    private void Update()
    {
        if (_camera == null)
        {
            return;
        }

        if (Input.GetMouseButtonDown(1))
        {
            RaycastHit hitInfo = new RaycastHit();
            bool       hit     = Physics.Raycast(_camera.ScreenPointToRay(Input.mousePosition), out hitInfo);

            if (hit)
            {
                // Checks if it is selectable
                Selectable selectable = hitInfo.transform.GetComponentInParent <Selectable>();

                if (selectable != null)
                {
                    // If it was previously selected then hide the selection UI element.
                    if (selectable.Equals(_currentSelection))
                    {
                        HideIndicator();
                    }
                    else
                    {
                        ShowIndicator(selectable);
                    }
                }
                else
                {
                    // If it isn't a selectable object hides the indicator.
                    HideIndicator();
                }
            }
            else
            {
                // Hides selection UI
                HideIndicator();
            }
        }
    }
Esempio n. 2
0
        /// <summary>
        ///     Navigates through the selectables
        /// </summary>
        private void Navigate()
        {
            Selectable l_selectable = null;

            if (GameManager.Instance.GameController.MenuUp())
            {
                l_selectable = _selectables[_currentSelectableID].FindSelectableOnUp();
            }

            if (GameManager.Instance.GameController.MenuDown())
            {
                l_selectable = _selectables[_currentSelectableID].FindSelectableOnDown();
            }

            if (GameManager.Instance.GameController.MenuLeft())
            {
                l_selectable = _selectables[_currentSelectableID].FindSelectableOnLeft();
            }

            if (GameManager.Instance.GameController.MenuRight())
            {
                l_selectable = _selectables[_currentSelectableID].FindSelectableOnRight();
            }

            if (l_selectable != null)
            {
                l_selectable.Select();

                for (int i = 0; i < _selectables.Length; i++)
                {
                    if (l_selectable.Equals(_selectables[i]))
                    {
                        _currentSelectableID = i;

                        return;
                    }
                }
            }
        }