예제 #1
0
    void ChangeSelection(int _directionSign)
    {
        selectable = false;

        switch (Mathf.Sign(_directionSign))
        {
        case -1:
            if (currentlySelectedButtonIndex == customButtons.Length - 1)
            {
                currentlySelectedButtonIndex = 0;
            }
            else
            {
                currentlySelectedButtonIndex++;
            }
            break;

        case 1:
            if (currentlySelectedButtonIndex == 0)
            {
                currentlySelectedButtonIndex = customButtons.Length - 1;
            }
            else
            {
                currentlySelectedButtonIndex--;
            }
            break;
        }

        currentlySelectedButton?.Deselect();
        currentlySelectedButton = customButtons[currentlySelectedButtonIndex];
        currentlySelectedButton.Select();
    }