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;
}
}
![alt text][1]
[1]: /storage/temp/132808-screen-shot-2019-02-08-at-102804-pm.png
↧