Description
The GetButtonOrigin
method in the Sandbox.Input
class is used to retrieve the origin of a button input as a string. This can be useful for displaying the source of an input action, such as a keyboard key or a game controller button, in a user interface or for debugging purposes.
Usage
To use the GetButtonOrigin
method, call it with the name of the button and a boolean indicating whether to ignore the controller input. The method will return a string representing the origin of the button input.
Parameters:
name
(System.String): The name of the button whose origin you want to retrieve.
ignoreController
(System.Boolean): A boolean value indicating whether to ignore controller input. If set to true
, the method will not consider controller inputs when determining the button origin.
Returns: A System.String
representing the origin of the specified button input.
Example
// Example usage of GetButtonOrigin
string buttonName = "Jump";
bool ignoreController = false;
string buttonOrigin = Input.GetButtonOrigin(buttonName, ignoreController);
// Output the button origin
// This could be used to display the input source in a UI
debugger.Log(buttonOrigin);