Class BaseInput
Interface to the Input system used by the BaseInputModule. With this it is possible to bypass the Input system with your own but still use the same InputModule. For example this can be used to feed fake input into the UI or interface with a different input system.
Inherited Members
Namespace: UnityEngine.EventSystems
Assembly: UnityEngine.UI.dll
Syntax
public class BaseInput : UIBehaviour
Properties
compositionCursorPos
Interface to Input.compositionCursorPos. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual Vector2 compositionCursorPos { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
compositionString
Interface to Input.compositionString. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual string compositionString { get; }
Property Value
| Type | Description |
|---|---|
| string |
imeCompositionMode
Interface to Input.imeCompositionMode. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual IMECompositionMode imeCompositionMode { get; set; }
Property Value
| Type | Description |
|---|---|
| IMECompositionMode |
mousePosition
Interface to Input.mousePosition. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual Vector2 mousePosition { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
mousePresent
Interface to Input.mousePresent. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual bool mousePresent { get; }
Property Value
| Type | Description |
|---|---|
| bool |
mouseScrollDelta
Interface to Input.mouseScrollDelta. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual Vector2 mouseScrollDelta { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
mouseScrollDeltaPerTick
The magnitude of mouseScrollDelta that corresponds to exactly one tick of the scroll wheel.
Declaration
public virtual float mouseScrollDeltaPerTick { get; }
Property Value
| Type | Description |
|---|---|
| float |
touchCount
Interface to Input.touchCount. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual int touchCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
touchSupported
Interface to Input.touchSupported. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual bool touchSupported { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
GetAxisRaw(string)
Interface to Input.GetAxisRaw. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual float GetAxisRaw(string axisName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | axisName | Axis name to check |
Returns
| Type | Description |
|---|---|
| float |
GetButtonDown(string)
Interface to Input.GetButtonDown. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual bool GetButtonDown(string buttonName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | buttonName | Button name to get |
Returns
| Type | Description |
|---|---|
| bool |
GetMouseButton(int)
Interface to Input.GetMouseButton. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual bool GetMouseButton(int button)
Parameters
| Type | Name | Description |
|---|---|---|
| int | button |
Returns
| Type | Description |
|---|---|
| bool |
GetMouseButtonDown(int)
Checks whether the user pressed the specified mouse button during this frame.
Declaration
public virtual bool GetMouseButtonDown(int button)
Parameters
| Type | Name | Description |
|---|---|---|
| int | button | The mouse button index to check, where 0 is left, 1 is right, and 2 is middle. |
Returns
| Type | Description |
|---|---|
| bool | true if the user pressed the specified mouse button during this frame; otherwise, false. |
Remarks
Override this method in a custom input module to supply your own mouse button logic. The default implementation forwards to Unity's GetMouseButtonDown(int). Use this when implementing custom input or testing without device input.
Examples
Override to supply custom mouse button input (for example, for testing). The following example simulates a left click when the user presses Space.
public override bool GetMouseButtonDown(int button)
{
// For example, simulate a left click when the user presses the Space key.
if (button == 0 && Input.GetKeyDown(KeyCode.Space))
return true;
return Input.GetMouseButtonDown(button);
}
GetMouseButtonUp(int)
Interface to Input.GetMouseButtonUp. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual bool GetMouseButtonUp(int button)
Parameters
| Type | Name | Description |
|---|---|---|
| int | button |
Returns
| Type | Description |
|---|---|
| bool |
GetTouch(int)
Interface to Input.GetTouch. Can be overridden to provide custom input instead of using the Input class.
Declaration
public virtual Touch GetTouch(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Touch index to get |
Returns
| Type | Description |
|---|---|
| Touch |