Search Unity

4.6 uGUI Mobile - Touch Button not working.

Discussion in 'UGUI & TextMesh Pro' started by infinitypbr, Sep 4, 2014.

  1. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    I have a button that starts the game. In the editor it works fine -- click it changes color and starts the game (loads new scene).

    On mobile it changes color when selected/clicked but stays in the "Active" color, without calling the function it's supposed to call.

    Any ideas why this may be happening?

    I've also done it with an event for "pointer click", same deal -- works fine in the editor (gets two debug logs for the function, since both on click and event pointer click are working), but not at all via touch.

    UPDATE: If i touch the button repeatedly it seems to eventually work. After maybe 5 seconds of tapping.

    SIde note: It seems possible to select 2 or 3 buttons at once. (yellow is my "is pressed" color, and all three buttons were able to turn yellow at once if I spammed them with my fingers)
     
    MohanadHamed likes this.
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    We have some bugs on the touch input module that we need to investigate.
     
    Djamahl and RogueCode like this.
  3. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    K, Cool. The actual game scene which has buttons being held down for moving/shooting works fine it seems.
     
  4. MohanadHamed

    MohanadHamed

    Joined:
    Sep 18, 2013
    Posts:
    3
    I am facing the same issue, I hope that this will be fixed in released update.
     
  5. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    All the issues I had above have been fixed in b19. b20 is out now, so there shouldn't be these same issues anymore.
     
  6. Louis-N-D

    Louis-N-D

    Joined:
    Apr 17, 2013
    Posts:
    224
    I have just experienced the exact same behaviour mentioned above but in RC2. Booh. Same deal. I can get the button to work by tapping on it with very quick short taps eventually. But it's mega janky.
     
  7. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    253
    Yeah same problem here in RC2.
    I'm using animations to control the menu's and works fine on Editor, but can't get any response from the mobile.

    2014-11-23.png
     
  8. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    253
    Hmmm, on further testing, the button OnClick() is working on the mobile, but animations aren't playing.
    Again, the animations work in the Editor, but not on the mobile.
     
  9. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    253
    It's all working fine in RC3!

    Thanks guys :)

    [EDIT] It's broke again. See below :(
     
    Last edited: Nov 24, 2014
  10. Louis-N-D

    Louis-N-D

    Joined:
    Apr 17, 2013
    Posts:
    224
    Nah. Just built in RC3 and all the touch stuff if totally messed up on my iPod including buttons, scroll rect and scroll bar.
     
  11. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    I don't know if it is related but I had some issues trying to figure why some of my buttons were not taking a ONClick. After trial and error I found two scroll bar Handles on unrelated UI gameobjects that had NaN as the top and bottom values. If Disabled that scrollBar handle then my buttons are pressable. If I re-enable the handle then they are not.

    On one scroll bar I was able to reset the value from Nan to -10 which seems to be the default but on the other handle it will not let me over ride it so there must be something else int the layout that is causing this behavior.

    I am not sure if I should open a bug a I might just have something misconfigured but I am not sure what that could be.

    iByte
     
    Last edited: Nov 24, 2014
  12. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    253
    Hmmm, I made some big changes to my uGUI and now the animations stopped working agian on the mobile :(
    Sigh... They say RC3 will be the final release. I'm worried!
     
  13. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    253
    OK, So I Installed KGFDebug because I noticed slight delay when I press the button on the mobile. I had a feeling there was a Null Reference going on there somewhere and sure as eggs, here's the screenshot from my mobile.
    Again, this works in Editor :mad:
    Screenshot_2014-11-25-00-27-37.png
     
  14. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    253
    OK, I nutted out where the error is...
    For some reason the OnClick() section to my script won't accept objects.
    I can pass int and string fine, but any objects (I tried Animator and GameObject) seems to cause the Null Reference error.
    I can work around it, but it's kind of annoying.

    Cheers :/
     
  15. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    253
    Do you have any OnClick() events pointing to scripts that pass objects?
    If so this may be the cause of your problems too. See my post above.
    Good luck :)
    2014-11-25.png
     
  16. eXiin

    eXiin

    Joined:
    Dec 23, 2013
    Posts:
    63
    I have a similar issue on Android with RC3.
    If I hold my finger on the button for half a second it works, but if I tap faster, it behave more like a 'hover'
     
  17. Louis-N-D

    Louis-N-D

    Joined:
    Apr 17, 2013
    Posts:
    224
    I'll give this a look when I get the chance. I really hope it's something I can fix on my end since the 4.6 release is right around the corner!
     
  18. Fragfire

    Fragfire

    Joined:
    Apr 15, 2014
    Posts:
    9
    Same problem here. The passing of objects gives me null reference exceptions. It worked fine before (b18 I think), but after the update to 4.6.1 my whole menu structure stopped working, because I pass them as objects >.<
     
  19. willybraun84

    willybraun84

    Joined:
    Aug 19, 2014
    Posts:
    2
    I have the same problem with the latest Unity3d 4.6 Version (4.6.1p3). The default OnClick event of a button does not work at all for mobile devices (android and iOS), but it works in the editor. If i tab on a button on a mobile device, is see only the pressed or hover animation, but no click event is raised. I can raise a click event, when I am tapping repeatedly very fast on a button for about 5 seconds or so.

    Is a bugfix in the works or should I use the PointerDown and PointerUp events to handle a click?
     
    Last edited: Jan 14, 2015
  20. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    we'd need to know about the bug to have a bugfix in the works. Could you file a report.
     
  21. willybraun84

    willybraun84

    Joined:
    Aug 19, 2014
    Posts:
    2
    I will post a detailed bugreport later today, but I have the feeling that it is generally not working with the latest patch release (4.6.1p3).
    I think you can create a new project and a new scene and add an UI canvas and an UI button to the scene. Then create a new c# script, by using the "Add Component" button within the UI button and add an empty method to the script, like:
    public void MyClick()
    {
    Debug.Log("Click");
    }

    Then add the method to the OnClick event of the button and compile the scene for an android or ios device.
    I think then you will see that the click is not raised at all or raised randomly by tapping very often on the button.
     
  22. Setsuki

    Setsuki

    Joined:
    Aug 21, 2012
    Posts:
    31
    I agree with WillyBraun84.
    To be very exact, I have personnally no trouble using the buttons on a touchscreen, but some of my betatesters do.
    Watching them struggling with the buttons, I noticed that they tend to press the button for a short moment, and I tend to very quickly tap. I think the problem is that the button doesn't work if :
    • the user start pressing the button
    • his finger slips a few pixels
    • the user releases the button
    I removed every action the button calls, added an event trigger using PointerUp to do it instead. My testers noticed the change for the better.

    Creating a bug report, I noticed a very important detail : it only happens in a scrollRect
     
    Last edited: Feb 3, 2015
    Ava42 and kayy like this.
  23. turbonabi

    turbonabi

    Joined:
    Nov 6, 2014
    Posts:
    1
    I had exact same problem (The buttons on scrollrect were throwing exceptions) and wasted a few hours.
    Then, somehow, I decided to switch "Scripting Backend" (PlayerSettings -> Other Settings -> Configuration) from Mono to IL2CPP, and everything seems working fine. (I don't know exactly how it works though)

    for more info
    http://docs.unity3d.com/Manual/iphone-64bit.html
     
  24. ercu

    ercu

    Joined:
    Aug 29, 2013
    Posts:
    6
    For my case, onClick does not work always for a regular button. Because pointerUp is not called always! so i ended up using only Down event instead of click.
     
  25. Ava42

    Ava42

    Joined:
    Aug 4, 2012
    Posts:
    33
    in Unity 4.6.3f1 IOS build still buttons not working well...
    >>I noticed that they tend to press the button for a short moment, and I tend to very quickly tap.
    in my case long (normal speed) taps ignored (butt hover color on button is changed)
    and only very fast taps react immediately.

    where we can find that bugreport?
     
  26. Ava42

    Ava42

    Joined:
    Aug 4, 2012
    Posts:
    33
    solved for me.
    In "EventSystem" -> "Standalone Input Manager" -> disable "Allow activation on mobile devices".
    then taps works immediately.
     
    f4bo likes this.
  27. f4bo

    f4bo

    Joined:
    Oct 7, 2014
    Posts:
    21
    man thanks a lot, I owe you a beer (and maybe a succulent steak as well) - I was bashing my head on the desk for hours. I wonder what that module is used for beside disrupting the mobile input
     
  28. Storyclock

    Storyclock

    Joined:
    May 29, 2015
    Posts:
    3
    solved for me too!!!! Thank you Ava42
    In "EventSystem" -> "Standalone Input Manager" -> disable "Allow activation on mobile devices".
    then taps works immediately.
     
  29. crafTDev

    crafTDev

    Joined:
    Nov 5, 2008
    Posts:
    1,820
    This works for me! Is this the intended behavior? If not, how come Unity hasn't fixed this yet?

    Thank you though!
     
  30. shawnrevels

    shawnrevels

    Joined:
    Aug 13, 2014
    Posts:
    86
    What about allow activation on stadalone in input section? Should that be ticked or not.
     
  31. Nabil_fx

    Nabil_fx

    Joined:
    Nov 9, 2013
    Posts:
    124
    my script does not work, i disable the EventSystem" -> "Standalone Input Manager" -> disable "Allow activation on mobile devices.

    but still does not work, the button is working

    here the script, please help. using Unity 5

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4.  
    5. public class LoginSystem : MonoBehaviour {
    6.  
    7.     public enum lMode{login,register};
    8.     public lMode LoginMode;
    9.  
    10.     public GUISkin skin;
    11.     //login
    12.     private string user = "";
    13.     private string pass = "";
    14.     private int    boolstatus;
    15.     //register
    16.     private string name = "";
    17.     private string password = "";
    18.     private string email = "";
    19.  
    20.     private string Log;
    21.     public Texture LogTexture;
    22.  
    23.     public string sceneMap;
    24.     [System.Serializable]
    25.     public class LoginParameters{
    26.         public Text LoginString;
    27.         public Text PassString;
    28.         public Toggle Remember;
    29.     }
    30.     [System.Serializable]
    31.     public class RegisterParameters{
    32.         public Text UserString;
    33.         public Text PassString;
    34.         public Text EmailString;
    35.     }
    36.  
    37.     public LoginParameters LP;
    38.     public RegisterParameters RP;
    39.  
    40.     public static int score;
    41.     public static string userName;
    42.  
    43.     private string[] ListStrings;
    44.  
    45.     public GameObject LoginM;  
    46.     public GameObject RegisM;
    47.  
    48.     public Text logText;
    49.  
    50.     void Start () {
    51.         boolstatus = PlayerPrefs.GetInt("bs");
    52.         if (boolstatus == 1) {
    53.             LP.Remember.isOn = true;
    54.         }else{
    55.             LP.Remember.isOn = false;
    56.         }
    57.         if (LP.Remember.isOn == true) user = PlayerPrefs.GetString ("login");
    58.     }
    59.  
    60.     void Update () {
    61.         logText.text = Log;
    62.         if (LoginMode == lMode.login) {
    63.             LoginM.SetActive(true);
    64.             RegisM.SetActive(false);
    65.         }else if(LoginMode == lMode.register){
    66.             LoginM.SetActive(false);
    67.             RegisM.SetActive(true);
    68.         }
    69.         if (LP.Remember.isOn == true) {
    70.             PlayerPrefs.SetString("login",user);
    71.             boolstatus = 1;
    72.             PlayerPrefs.SetInt("bs",boolstatus);
    73.         }else{
    74.             boolstatus = 0;
    75.             PlayerPrefs.SetInt("bs",boolstatus);
    76.         }
    77.  
    78.     }
    79.     void OnGUI(){
    80.         GUI.skin = skin;
    81.     }
    82.     void RequestRegister(){
    83.         name  = RP.UserString.text;
    84.         email = RP.EmailString.text;
    85.         password = RP.PassString.text;
    86.         if (name.Length < 1) {
    87.             Log = "Preencha o campo do Usuário.";
    88.         }else{
    89.             if(email.Length < 1){
    90.                 Log = "Preencha o campo do E-Mail.";
    91.             }else{
    92.                 if(password.Length < 1){
    93.                     Log = "Preencha o campo da Senha.";
    94.                 }else{
    95.                     WWWForm register = new WWWForm();
    96.                     register.AddField("user",name);
    97.                     register.AddField("pass",password);
    98.                     register.AddField("email",email);
    99.                     WWW w = new WWW("http://nfx.comuv.com/register.php",register);
    100.                     StartCoroutine(RequestRegisterInformations(w));
    101.                 }
    102.             }
    103.         }
    104.     }
    105.     void RequestLogin(){
    106.         user = LP.LoginString.text;
    107.         pass = LP.PassString.text;
    108.         Log = "";
    109.         if (user.Length < 1) {
    110.             Log = "Preencha o campo do usuario";
    111.         }else{
    112.             if(pass.Length < 1){
    113.                 Log = "Preencha o campo da senha";
    114.             }else{
    115.                 WWWForm login = new WWWForm();
    116.                 login.AddField("user",user);
    117.                 login.AddField("pass",pass);
    118.                 WWW w = new WWW("http://nfx.comuv.com/Login.php",login);
    119.                 StartCoroutine(RequestLoginInformations(w));
    120.             }
    121.         }
    122.     }
    123.     IEnumerator RequestLoginInformations(WWW w){
    124.         yield return w;
    125.         if (w.error == null) {
    126.             Log = w.text;
    127.             ListStrings = w.text.Split(';');
    128.             if(ListStrings[0] == "Bem vindo"){
    129.                 Log = "Seja " + ListStrings[0] + " " + ListStrings[1] +" ";
    130.                 userName = ListStrings[1];
    131.             }
    132.             if(ListStrings[0] == "Bem vindo"){
    133.                 Application.LoadLevel(sceneMap);
    134.             }
    135.         }
    136.     }
    137.     IEnumerator RequestRegisterInformations(WWW w){
    138.         yield return w;
    139.         if (w.error == null) {
    140.             Log = w.text;
    141.             if(Log == "Conta criada com sucesso!"){
    142.                 LP.LoginString.text = RP.UserString.text;
    143.                 LP.PassString.text = RP.PassString.text;
    144.                 RP.UserString.text = "";
    145.                 RP.EmailString.text = "";
    146.                 RP.PassString.text = "";
    147.                 LoginMode = lMode.login;
    148.             }
    149.         }
    150.     }
    151.     void RegisterMode(){
    152.         LoginMode = lMode.register;
    153.     }
    154.     void LoginMod(){
    155.         LoginMode = lMode.login;
    156.     }
    157. }
    158.  
     
  32. Chrisad

    Chrisad

    Joined:
    Mar 12, 2013
    Posts:
    55
    I have exactly the same problem than eXiin in Unity 5.2.1 on iOS...
     
  33. BioeJD

    BioeJD

    Joined:
    Mar 11, 2016
    Posts:
    6
    I'm having this same issue in 5.3.1
     
  34. IndieGeek

    IndieGeek

    Joined:
    Sep 30, 2016
    Posts:
    16
    There is no option of "Allow activation on mobile devices" in "Standalone Input Manager". I'm using Unity 5.4.1
    Please help me out too!