Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

GetButtonUp

Jibran Syed edited this page Jan 30, 2016 · 8 revisions

<- Back to Coding References

Signature

static bool GetButtonUp(XboxButton button);
static bool GetButtonUp(XboxButton button, XboxController controller);

Description

GetButtonUp() returns true the moment the specified XboxButton was released. The button had to be pressed down prior, and then released. It will return false any frame after the moment the button was released. This is useful for interacting with menu selection with an Xbox controller, for example.

Parameters

  • XboxButton button : An identifier for the Xbox button you want to test. Please refer to XboxButton for all possible buttons.

  • XboxController controller : An identifier for the specific controller on which to test the button. If this parameter isn't provided, all connected controllers will be tested for the specified button. It is recommended to omit this parameter if you are making a single player game. Please refer to XboxController for all possible controllers.

Example

The example demonstrates the use of GetButtonDown() if you wanted any player to select "Begin Game" with the 'Start' button.

using UnityEngine;
using XboxCtrlrInput;

public class MenuExample : MonoBehavior
{
    public bool isBeginGameSelected = true;    

    void Update()
    {
        if( XCI.GetButtonUp(XboxButton.Start) )
        {
            if(isBeginGameSelected)
            {
                // Begin the game
                Application.LoadLevel("scnLevel1");
            }
        }
    }
}

Button Map

ButtonMap

<- Back to Coding References

Clone this wiki locally