Class BaseInputModule
Inherited Members
Namespace: UnityEngine.EventSystems
Assembly: UnityEngine.UI.dll
Syntax
[RequireComponent(typeof(EventSystem))]
public abstract class BaseInputModule : UIBehaviour
Fields
m_InputOverride
Declaration
protected BaseInput m_InputOverride
Field Value
Type | Description |
---|---|
BaseInput |
m_RaycastResultCache
Declaration
[NonSerialized]
protected List<RaycastResult> m_RaycastResultCache
Field Value
Type | Description |
---|---|
List<RaycastResult> |
Properties
eventSystem
Declaration
protected EventSystem eventSystem { get; }
Property Value
Type | Description |
---|---|
EventSystem |
input
The current BaseInput being used by the input module.
Declaration
public BaseInput input { get; }
Property Value
Type | Description |
---|---|
BaseInput |
inputOverride
Used to override the default BaseInput for the input module.
Declaration
public BaseInput inputOverride { get; set; }
Property Value
Type | Description |
---|---|
BaseInput |
Remarks
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.
sendPointerHoverToParent
True if pointer hover events will be sent to the parent
Declaration
protected bool sendPointerHoverToParent { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
ActivateModule()
Called when the module is activated. Override this if you want custom code to execute when you activate your module.
Declaration
public virtual void ActivateModule()
ConvertPointerEventScrollDeltaToTicks(Vector2)
Converts PointerEventData.scrollDelta to corresponding number of ticks of the scroll wheel.
Declaration
public virtual Vector2 ConvertPointerEventScrollDeltaToTicks(Vector2 scrollDelta)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | scrollDelta |
Returns
Type | Description |
---|---|
Vector2 |
Remarks
Input Module implementations are free to apply a scaling factor to their PointerEventData's scrollDelta. This method can be used when a system needs to treat scaling-independent input values.
ConvertUIToolkitPointerId(PointerEventData)
Returns Id of the pointer following PointerId convention.
Declaration
public virtual int ConvertUIToolkitPointerId(PointerEventData sourcePointerData)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | sourcePointerData | PointerEventData whose pointerId will be converted to UI Toolkit pointer convention. |
Returns
Type | Description |
---|---|
int |
See Also
DeactivateModule()
Called when the module is deactivated. Override this if you want custom code to execute when you deactivate your module.
Declaration
public virtual void DeactivateModule()
DetermineMoveDirection(float, float)
Given an input movement, determine the best MoveDirection.
Declaration
protected static MoveDirection DetermineMoveDirection(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
float | x | X movement. |
float | y | Y movement. |
Returns
Type | Description |
---|---|
MoveDirection |
DetermineMoveDirection(float, float, float)
Given an input movement, determine the best MoveDirection.
Declaration
protected static MoveDirection DetermineMoveDirection(float x, float y, float deadZone)
Parameters
Type | Name | Description |
---|---|---|
float | x | X movement. |
float | y | Y movement. |
float | deadZone | Dead zone. |
Returns
Type | Description |
---|---|
MoveDirection |
FindCommonRoot(GameObject, GameObject)
Given 2 GameObjects, return a common root GameObject (or null).
Declaration
protected static GameObject FindCommonRoot(GameObject g1, GameObject g2)
Parameters
Type | Name | Description |
---|---|---|
GameObject | g1 | GameObject to compare |
GameObject | g2 | GameObject to compare |
Returns
Type | Description |
---|---|
GameObject |
FindFirstRaycast(List<RaycastResult>)
Return the first valid RaycastResult.
Declaration
protected static RaycastResult FindFirstRaycast(List<RaycastResult> candidates)
Parameters
Type | Name | Description |
---|---|---|
List<RaycastResult> | candidates |
Returns
Type | Description |
---|---|
RaycastResult |
GetAxisEventData(float, float, float)
Given some input data generate an AxisEventData that can be used by the event system.
Declaration
protected virtual AxisEventData GetAxisEventData(float x, float y, float moveDeadZone)
Parameters
Type | Name | Description |
---|---|---|
float | x | X movement. |
float | y | Y movement. |
float | moveDeadZone |
Returns
Type | Description |
---|---|
AxisEventData |
GetBaseEventData()
Generate a BaseEventData that can be used by the EventSystem.
Declaration
protected virtual BaseEventData GetBaseEventData()
Returns
Type | Description |
---|---|
BaseEventData |
HandlePointerExitAndEnter(PointerEventData, GameObject)
Declaration
protected void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget)
Parameters
Type | Name | Description |
---|---|---|
PointerEventData | currentPointerData | |
GameObject | newEnterTarget |
IsModuleSupported()
Check to see if the module is supported. Override this if you have a platform specific module (eg. TouchInputModule that you do not want to activate on standalone.)
Declaration
public virtual bool IsModuleSupported()
Returns
Type | Description |
---|---|
bool | Is the module supported. |
IsPointerOverGameObject(int)
If the module is pointer based, then override this to return true if the pointer is over an event system object.
Declaration
public virtual bool IsPointerOverGameObject(int pointerId)
Parameters
Type | Name | Description |
---|---|---|
int | pointerId | Pointer ID |
Returns
Type | Description |
---|---|
bool | Is the given pointer over an event system object? |
OnDisable()
Declaration
protected override void OnDisable()
Overrides
OnEnable()
Declaration
protected override void OnEnable()
Overrides
Process()
Process the current tick for the module.
Declaration
public abstract void Process()
ShouldActivateModule()
Should the module be activated.
Declaration
public virtual bool ShouldActivateModule()
Returns
Type | Description |
---|---|
bool |
UpdateModule()
Update the internal state of the Module.
Declaration
public virtual void UpdateModule()