C# Класс OVRInputControl

Cross-platform wrapper for Unity Input. See OVRGamepadController for a list of the base axis and button names. Depending on joystick number and platform the base names will be pre-pended with "Platform:Joy #:" to look them up in the Unity Input table. For instance: using an axis name of "Left_X_Axis" with GetJoystickAxis() will result in looking up the axis named "Win: Joy 1: Left_X_Axis" when running on Windows and "Android: Joy 1: Left_X_Axis" when running on Android. In addition to wrapping joystick input, this class allows the assignment of up, held and down events for any key, mouse button, or joystick button via the AddInputHandler() method. Currently this class relies on enumerations defined in OVRGamepadController so that it remains compatible with existing Unity OVR projects. When this class is included it overloads the default GPC_GetAxis() and GPC_GetButton() calls to to ReadAxis() and ReadButton() in this class. Ideally this class would completely replace the OVRGamepadController class. This would involve changing the GPC_GetAxis() and GPC_GetButton() calls in a project and removing references to OVRGamepadController in this file (and moving some of the tables to InputControl).
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
verbose bool

Открытые методы

Метод Описание
AddInputHandler ( DeviceType dt, MouseButton, mouseButton, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void

Adds a handler for mouse button input.

AddInputHandler ( DeviceType dt, OVRGamepadController, joystickButton, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void

Adds a handler for joystick button input.

AddInputHandler ( DeviceType dt, string keyName, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void

Adds a handler for key input

AddInputMapping ( int joystickNumber, MonoBehaviour comp ) : void

Adds a mapping from a joystick to a behavior.

ClearControlMappings ( ) : void

Removes all control mappings.

GetJoystickAxis ( int joystickNumber, OVRGamepadController, axis ) : float

Delegate for OVRGamepadController. Returns the current value of the specified joystick axis.

GetJoystickAxis ( int joystickNumber, string name ) : float

Returns the current value of the joystick axis specified by the name parameter. The name should partially match the name of an axis specified in the Unity Edit -> Project Settings -> Input pane, minus the Platform: Joy #: qualifiers. For instance, specify "Left_X_Axis" to select the appropriate axis for the current platform. This will be permuted into something like "Win:Joy 1:Left_X_Axis" before it is queried.

GetJoystickButton ( int joystickNumber, OVRGamepadController, button ) : bool

Delegate for OVRGamepadController. Returns true if the specified joystick button is pressed.

GetJoystickButton ( int joystickNumber, string name ) : bool

Returns true if a joystick button is depressed. The name should partially match the name of an axis specified in the Unity Edit -> Project Settings -> Input pane, minus the Platform: Joy #: qualifiers. For instance, specify "Button A" to select the appropriate axis for the current platform. This will be permuted into something like "Win:Joy 1:Button A" before it is queried.

GetMouseButton ( MouseButton, button ) : bool
ReadJoystickAxis ( OVRGamepadController, axis ) : float

Delegate for OVRGamepadController. This only exists for legacy compatibility with OVRGamepadController.

ReadJoystickButton ( OVRGamepadController, button ) : bool

Delegate for OVRGamepadController. This only exists for legacy compatibility with OVRGamepadController.

RemoveInputMapping ( int joystickNumber, MonoBehaviour comp ) : void

Removes a mapping from a joystick to a behavior.

Update ( ) : void

Updates the state of all input mappings. This must be called from a single MonoBehaviour's Update() method for input to be read.

Приватные методы

Метод Описание
Init_Android ( ) : void

Initializes the input system for Android.

Init_OSX ( ) : void

Initializes the input system for OSX.

Init_OSX_Editor ( ) : void

Initializes the input system for OSX when running from the Unity editor.

Init_Windows ( ) : void

Initializes the input system for OSX.

Init_Windows_Editor ( ) : void

Initializes the input system for Windows when running from the Unity editor.

Init_iPhone ( ) : void

Initializes the input system for iPhone.

OVRInputControl ( ) : UnityEngine

Static contructor for the OVRInputControl class.

ShowAxisValues ( ) : void

Outputs debug spam for any non-zero axis. This is only used for finding which axes are which with new controllers.

ShowButtonValues ( ) : void

Outputs debug spam for any depressed button. This is only used for finding which buttons are which with new controllers.

UpdateInputMapping ( int joystickNumber, MonoBehaviour comp ) : void

Updates a single input mapping.

Описание методов

AddInputHandler() публичный статический Метод

Adds a handler for mouse button input.
public static AddInputHandler ( DeviceType dt, MouseButton, mouseButton, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void
dt DeviceType
mouseButton MouseButton,
onDown OnKeyDown,
onHeld OnKeyHeld
onUp OnKeyUp
Результат void

AddInputHandler() публичный статический Метод

Adds a handler for joystick button input.
public static AddInputHandler ( DeviceType dt, OVRGamepadController, joystickButton, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void
dt DeviceType
joystickButton OVRGamepadController,
onDown OnKeyDown,
onHeld OnKeyHeld
onUp OnKeyUp
Результат void

AddInputHandler() публичный статический Метод

Adds a handler for key input
public static AddInputHandler ( DeviceType dt, string keyName, OnKeyDown, onDown, OnKeyHeld onHeld, OnKeyUp onUp ) : void
dt DeviceType
keyName string
onDown OnKeyDown,
onHeld OnKeyHeld
onUp OnKeyUp
Результат void

AddInputMapping() публичный статический Метод

Adds a mapping from a joystick to a behavior.
public static AddInputMapping ( int joystickNumber, MonoBehaviour comp ) : void
joystickNumber int
comp MonoBehaviour
Результат void

ClearControlMappings() публичный статический Метод

Removes all control mappings.
public static ClearControlMappings ( ) : void
Результат void

GetJoystickAxis() публичный статический Метод

Delegate for OVRGamepadController. Returns the current value of the specified joystick axis.
public static GetJoystickAxis ( int joystickNumber, OVRGamepadController, axis ) : float
joystickNumber int
axis OVRGamepadController,
Результат float

GetJoystickAxis() публичный статический Метод

Returns the current value of the joystick axis specified by the name parameter. The name should partially match the name of an axis specified in the Unity Edit -> Project Settings -> Input pane, minus the Platform: Joy #: qualifiers. For instance, specify "Left_X_Axis" to select the appropriate axis for the current platform. This will be permuted into something like "Win:Joy 1:Left_X_Axis" before it is queried.
public static GetJoystickAxis ( int joystickNumber, string name ) : float
joystickNumber int
name string
Результат float

GetJoystickButton() публичный статический Метод

Delegate for OVRGamepadController. Returns true if the specified joystick button is pressed.
public static GetJoystickButton ( int joystickNumber, OVRGamepadController, button ) : bool
joystickNumber int
button OVRGamepadController,
Результат bool

GetJoystickButton() публичный статический Метод

Returns true if a joystick button is depressed. The name should partially match the name of an axis specified in the Unity Edit -> Project Settings -> Input pane, minus the Platform: Joy #: qualifiers. For instance, specify "Button A" to select the appropriate axis for the current platform. This will be permuted into something like "Win:Joy 1:Button A" before it is queried.
public static GetJoystickButton ( int joystickNumber, string name ) : bool
joystickNumber int
name string
Результат bool

GetMouseButton() публичный статический Метод

public static GetMouseButton ( MouseButton, button ) : bool
button MouseButton,
Результат bool

ReadJoystickAxis() публичный статический Метод

Delegate for OVRGamepadController. This only exists for legacy compatibility with OVRGamepadController.
public static ReadJoystickAxis ( OVRGamepadController, axis ) : float
axis OVRGamepadController,
Результат float

ReadJoystickButton() публичный статический Метод

Delegate for OVRGamepadController. This only exists for legacy compatibility with OVRGamepadController.
public static ReadJoystickButton ( OVRGamepadController, button ) : bool
button OVRGamepadController,
Результат bool

RemoveInputMapping() публичный статический Метод

Removes a mapping from a joystick to a behavior.
public static RemoveInputMapping ( int joystickNumber, MonoBehaviour comp ) : void
joystickNumber int
comp MonoBehaviour
Результат void

Update() публичный статический Метод

Updates the state of all input mappings. This must be called from a single MonoBehaviour's Update() method for input to be read.
public static Update ( ) : void
Результат void

Описание свойств

verbose публичное статическое свойство

If true, prints information about each input event to the log.
public static bool verbose
Результат bool