Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

On Click Event

Discussion in '2D' started by whiteshark01, Nov 8, 2019.

  1. whiteshark01

    whiteshark01

    Joined:
    Mar 10, 2019
    Posts:
    14
    Hello. I am trying to make an app for mobile phones in Unity. Today I was looking for a video about changing scenes in unity. The youtuber who make the video said we should use EventTrigger instead of OnClickEvent because it is also working for mobile phones. I have two questions:
    1. Is OnClickEvent working for switching scenes on mobile phones?
    2. Does OnClickEvent work for switching between panels on mobile phone?
    Thank you.

    This is the video:

    He said about EventTrigger at 7:05
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi @whiteshark01

    "1. Is OnClickEvent working for switching scenes on mobile phones?"

    Make a build and try?

    "2. Does OnClickEvent work for switching between panels on mobile phone?"

    AFAIK uGUI button OnClick should work on mobile, even if it is called a "click".

    However, now that you asked, I googled about it, and seems like this thing you mention has been an issue, several discussions around the internet exists, like this one:

    https://answers.unity.com/questions/980121/ui-buttons-working-on-android.html

    Seems like issue might be with finger detected to be moving, resulting in drag instead of tap/button press. One solution suggested is to make drag threshold in UI EventSystem less precise:

    https://www.reddit.com/r/Unity3D/comments/a0i1km/how_to_make_ui_buttons_on_mobile_phone_more/
    https://docs.unity3d.com/Manual/script-EventSystem.html

    But in general, there is no need to use EventTrigger AFAIK. You'll probably have better luck asking this on your target mobile platform area (you didn't mention which platform you target).
     
    whiteshark01 likes this.
  3. whiteshark01

    whiteshark01

    Joined:
    Mar 10, 2019
    Posts:
    14
    I want to target both ios and android. I will try to make a build. I already found a video about it. While this is my first project I am a "noob" so I have to search for everything.Thank you for your time. One more question, do you ever used Unity Remote 5? I tryed to use it to test the game but I think I have some connection issues between my PC and phone(I have an iPhone X and a HP laptop with windows 10) because the app shuts down when I click on Play button.

    UPDATE: I read the discutions in the forum and I understand what is the issue. I test it in unity by moving the mouse a bit and than I increase sensitivity. Now it is working even if I move the mouse a bit. Thank you for your help.

    I still have this question:
    "One more question, do you ever used Unity Remote 5? I tryed to use it to test the game but I think I have some connection issues between my PC and phone(I have an iPhone X and a HP laptop with windows 10) because the app shuts down when I click on Play button."
     
    Last edited: Nov 8, 2019
  4. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @whiteshark01

    You'll have to ask someone else - I have used remote, but with different devices and it has been quite a while...
     
    whiteshark01 likes this.
  5. whiteshark01

    whiteshark01

    Joined:
    Mar 10, 2019
    Posts:
    14
    Ok.Thank you. I solve the first problem.