Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    48
    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

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

    Yeowza

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

    Yeowza

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