Exemple #1
0
    void Update()
    {
        if (inputDelayCounter > 0)
        {
            inputDelayCounter -= Time.deltaTime;
        }
        else
        {
            inputDelayCounter = 0;
        }


        if (mapIndex == 0)
        {
            UpArrow.interactable   = false;
            DownArrow.interactable = true;
        }
        else if (mapIndex == Maps.Length - 1)
        {
            UpArrow.interactable   = true;
            DownArrow.interactable = false;
        }
        else
        {
            UpArrow.interactable   = true;
            DownArrow.interactable = true;
        }

        //poll players controllers
        var players = ReInput.players;

        for (int i = 0; i <= players.playerCount - 1; i++)
        {
            var player = players.GetPlayer(i);


            if (player.controllers.joystickCount > 0 && inputDelayCounter == 0)
            {
                Debug.Log(player.GetAxis(0) + " " + player.GetAxis(1));
                if (InputHelpers.MenuDownOrRight(player))
                {
                    DownArrowClicked();
                    inputDelayCounter = inputDelayTimer;
                }
                if (InputHelpers.MenuUpOrLeft(player))
                {
                    UpArrowClicked();
                    inputDelayCounter = inputDelayTimer;
                }
                if (InputHelpers.MenuAccept(player))
                {
                    MapClick();
                }
            }
        }
    }