A BaseInputModule for ray-based input, based on PointerInputModule
Inheritance
RayInputModule
public abstract class RayInputModule : BaseInputModule, IUsesViewerScale, IFunctionalitySubscriber<IProvidesViewerScale>, IFunctionalitySubscriber
Fields
Touch id for when simulating touches on a non touch device.
Declaration
public const int kFakeTouchesId = -4
Field Value
Id of the cached left mouse pointer event.
Declaration
public const int kMouseLeftId = -1
Field Value
Id of the cached middle mouse pointer event.
Declaration
public const int kMouseMiddleId = -3
Field Value
Id of the cached right mouse pointer event.
Declaration
public const int kMouseRightId = -2
Field Value
Declaration
protected Dictionary<int, RayEventData> m_RayData
Field Value
Methods
Declaration
protected override void Awake()
Clear all pointers and deselect any selected objects in the EventSystem.
Declaration
protected void ClearSelection()
Copy one RayEventData to another.
Declaration
protected void CopyFromTo(RayEventData from, RayEventData to)
Parameters
Deselect the current selected GameObject if the currently pointed-at GameObject is different.
Declaration
protected void DeselectIfSelectionChanged(GameObject currentOverGo, BaseEventData pointerEvent)
Parameters
Type |
Name |
Description |
GameObject |
currentOverGo |
The GameObject the pointer is currently over.
|
BaseEventData |
pointerEvent |
Current event data.
|
Return the last RayEventData for the given touch / mouse id.
Declaration
protected RayEventData GetLastRayEventData(int id)
Parameters
Type |
Name |
Description |
Int32 |
id |
|
Returns
Return the current MouseState. Using the default pointer.
Declaration
protected virtual RayInputModule.RayMouseState GetMouseRayEventData()
Returns
Return the current MouseState.
Declaration
protected virtual RayInputModule.RayMouseState GetMouseRayEventData(int id)
Parameters
Type |
Name |
Description |
Int32 |
id |
|
Returns
Search the cache for currently active pointers, return true if found.
Declaration
protected bool GetRayData(int id, out RayEventData data, bool create)
Parameters
Returns
Type |
Description |
Boolean |
True if pointer is found.
|
Given a touch populate the RayEventData and return if we are pressed or released.
Declaration
protected RayEventData GetTouchRayEventData(Touch input, out bool pressed, out bool released)
Parameters
Type |
Name |
Description |
Touch |
input |
Touch being processed
|
Boolean |
pressed |
Are we pressed this frame
|
Boolean |
released |
Are we released this frame
|
Returns
Declaration
protected void HandlePointerExitAndEnter(RayEventData eventData, GameObject newEnterTarget, bool exitOnly = false)
Parameters
Declaration
public override bool IsPointerOverGameObject(int pointerId)
Parameters
Type |
Name |
Description |
Int32 |
pointerId |
|
Returns
Declaration
protected void OnPointerUp(RayEventData rayEvent, GameObject currentOverGo)
Parameters
Type |
Name |
Description |
RayEventData |
rayEvent |
|
GameObject |
currentOverGo |
|
Process the drag for the current frame with the given pointer event.
Declaration
protected virtual void ProcessDrag(RayEventData rayEvent, bool useWorldPosition = false)
Parameters
Process movement for the current frame with the given pointer event.
Declaration
protected virtual void ProcessMove(RayEventData pointerEvent)
Parameters
Remove the RayEventData from the cache.
Declaration
protected void RemoveRayData(RayEventData data)
Parameters
Given a mouse button return the current state for the frame.
Declaration
protected PointerEventData.FramePressState StateForMouseButton(int buttonId)
Parameters
Type |
Name |
Description |
Int32 |
buttonId |
Mouse button ID
|
Returns
Type |
Description |
PointerEventData.FramePressState |
|
Declaration
public override string ToString()
Returns
Events
Declaration
public event Action<GameObject, RayEventData> dragEnded
Event Type
Declaration
public event Action<GameObject, RayEventData> dragStarted
Event Type
Declaration
public event Action<GameObject, RayEventData> rayEntered
Event Type
Declaration
public event Action<GameObject, RayEventData> rayExited
Event Type
Declaration
public event Action<GameObject, RayEventData> rayHovering
Event Type
Explicit Interface Implementations
Declaration
IProvidesViewerScale IFunctionalitySubscriber<IProvidesViewerScale>.provider { get; set; }
Returns
Implements
Extension Methods
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.