UI events not working on mobile

The UI event interfaces are working fine for me on PC with mouse but not working on mobile. Is that the correct behaviour?

I have a canvas with graphic raycaster, event system, and standalone input module added and a basic image inside the canvas that I am manipulating with this code.

    public void OnDrag(PointerEventData eventData)
    {
        this.transform.position = eventData.position;
        Debug.Log("DRAGGING");
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        Destroy(this.gameObject);
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        Debug.Log("soifsdofids");
    }

I think it should be working for mobiles also but it’s not. Any ideas?

Please post the output of your debug.log statements, they will show in the logcat logs.

The touch input module says it’s deprecated and that we are supposed to use the stand alone input module but there it does not say anything about mobile input in the documentation… Redirecting to latest version of com.unity.ugui

Thanks for reply. There are no messages, the events are not being triggered when I tap on screen, drag, etc etc.

When I use the Input class it works as expected…

if (UnityEngine.Input.touchCount > 0) { Destroy(this.gameObject); }

Not sure why UI events are not working though.

Ok problem was my fault, sorry. I created a duplicate scene yesterday for testing and forgot to switch to that in the build settings so every time I built the scene none of my changes were updated on mobile but were still displayed on PC. Nice way to spend half the day. :frowning:

2 Likes