Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

UI events not working on mobile

Discussion in 'Getting Started' started by Yeowza, Oct 7, 2019.

  1. Yeowza

    Yeowza

    Joined:
    May 9, 2014
    Posts:
    23
    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.

    Code (CSharp):
    1.     public void OnDrag(PointerEventData eventData)
    2.     {
    3.         this.transform.position = eventData.position;
    4.         Debug.Log("DRAGGING");
    5.     }
    6.  
    7.     public void OnPointerClick(PointerEventData eventData)
    8.     {
    9.         Destroy(this.gameObject);
    10.     }
    11.  
    12.     public void OnPointerEnter(PointerEventData eventData)
    13.     {
    14.         Debug.Log("soifsdofids");
    15.     }
    I think it should be working for mobiles also but it's not. Any ideas?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,449
    Please post the output of your debug.log statements, they will show in the logcat logs.
     
  3. Yeowza

    Yeowza

    Joined:
    May 9, 2014
    Posts:
    23
  4. Yeowza

    Yeowza

    Joined:
    May 9, 2014
    Posts:
    23
    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..

    Code (CSharp):
    1. if (UnityEngine.Input.touchCount > 0) { Destroy(this.gameObject); }
    Not sure why UI events are not working though.
     
    Last edited: Oct 7, 2019
  5. Yeowza

    Yeowza

    Joined:
    May 9, 2014
    Posts:
    23
    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. :(
     
    Joe-Censored and JeffDUnity3D like this.