Exemplo n.º 1
0
    void OnTouchPressed(Vector3 position)
    {
                #if UNITY_EDITOR
        _isTouchEnabled = (EventSystem.current == null || !EventSystem.current.IsPointerOverGameObject());
                #else
        _isTouchEnabled = (EventSystem.current == null || !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId));
                #endif

        if (!_isTouchEnabled)
        {
            return;
        }

        // Save touch position
        _touchPosition = position;

        _selectedMap = -1;

        Vector3 buttonPosition;
        float   deltaX, deltaY;

        int buttonCount = _buttons.Length;

        for (int i = 0; i < buttonCount; i++)
        {
            buttonPosition = _buttons[i].transform.position;

            deltaX = position.x - buttonPosition.x;
            deltaY = position.y - buttonPosition.y;

            if (deltaX * deltaX + deltaY * deltaY <= _squareRadius)
            {
                _selectedMap = i;
//				Debug.Log("Select map " + (_selectedMap + 1));

                break;
            }
        }

        _verticalScroll.OnTouchPressed(position);
    }