- Home /
EventSystem IDragHandler not working on iOS
I cannot figure out why this doesn't work. I'm trying to use the EventSystem to detect Drag events on a GameObject on iOS. Everything works fine in the Editor with a mouse. I have implemented OnBeginDrag, OnDrag, and OnEndDrag as shown in the DragPanel script below. The script is attached to a cube. The cube also has a Box Collider, an Event System, and a Standalone Input Module. The camera has a Physics Raycaster attached. What am I missing? Thanks in advance.
using UnityEngine;
using UnityEngine.EventSystems;
public class DragPanel : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public Material material;
public void OnBeginDrag(PointerEventData eventData)
{
Debug.Log("OnBeginDrag started ................................" + eventData.pointerCurrentRaycast.worldPosition);
material.color = Color.blue;
}
public void OnDrag(PointerEventData eventData)
{
Debug.Log("OnDrag called ................................" + eventData.pointerCurrentRaycast.worldPosition);
material.color = Color.blue;
}
public void OnEndDrag(PointerEventData eventData)
{
Debug.Log("OnEndDrag called ................................" + eventData.pointerCurrentRaycast.worldPosition);
material.color = Color.white;
}
}
Answer by dma8 · Feb 16, 2019 at 12:57 AM
Posting my solution in case anyone else is having trouble with this. For some reason the Max Ray Intersections on the Physics Raycaster must be set to zero to work on iOS.
I have found the same issue and constraint when building for WebGL. If the $$anonymous$$ax Ray Intersections on the Physics Raycaster is set to anything other than zero, no events are reported. Unity Editor version 2018.3.10f1
Your answer
Follow this Question
Related Questions
Check UI panel touched after OnEnable()? 0 Answers
Simultaneous Touch Drag Controls 0 Answers
How do i make a continuos touch that triggers more then one "button"? 1 Answer
Tap to Move Drag to Look Null Reference 1 Answer
Input across scripts 1 Answer