Search Unity

Linux build (64 bit and universal) doesn't respond to touch screen events. Linux Editor works.

Discussion in 'Linux' started by gloriajw, Apr 7, 2018.

  1. gloriajw

    gloriajw

    Joined:
    Mar 1, 2018
    Posts:
    6
    Hi all. In the Linux editor, my game works perfectly. Once I build for 64 bit or universal, the build doesn't see to register touch screen events. When I touch the screen, a keyboard comes up instead.

    Did I miss a build flag somewhere?
    Thank you in advance,

    Gary
     
  2. huno92

    huno92

    Joined:
    Oct 20, 2015
    Posts:
    14
    I guess you should provide some more information like for example how do you handle touch events, it works for me and I'm using mouse-up/down conditionals in the update function I've successfully built an android app and it works without issues. What version of the editor are you using. I've also built the universal linux version and it works as well so...
     
  3. gloriajw

    gloriajw

    Joined:
    Mar 1, 2018
    Posts:
    6
    I'm using the 2018.1.0b8 Linux build on a Fedora 27 OS.
    I inherited this game, and I'm still wading through the code, but found this comment in the shot manager code:
    Code (CSharp):
    1.  
    2.     //looks for input on movile or standalone/editor
    3.     void checkInput()
    4.     {
    5. #if UNITY_ANDROID || UNITY_IOS
    6.         if (Input.touchCount>0)
    7.         {
    8.             Ray ray = c.ScreenPointToRay(Input.touches[0].position);
    9.             RaycastHit hit = new RaycastHit();
    10.             if (Physics.Raycast(ray,out hit, 1000))
    11.             {
    12.                 Debug.DrawLine(cpos, hit.point);
    13.                 // cache oneSpawn object in spawnPt, if not cached yet
    14.  
    15.                 GameObject projectile = Instantiate(shotPrefab, new Vector3(cpos.x, cpos.y, cpos.z), Quaternion.identity);
    16.                 // turn the projectile to hit.point
    17.                 projectile.transform.LookAt(hit.point);
    18.                 // accelerate it
    19.                 projectile.GetComponent<Rigidbody>().velocity = projectile.transform.forward * 50;
    20.             }
    21.         }
    22. #endif
    23. #if UNITY_STANDALONE || UNITY_EDITOR
    24.         if (Input.GetMouseButtonDown(0))
    25.         {
    26.  
    27.             Ray ray = c.ScreenPointToRay(Input.mousePosition);
    28.             RaycastHit hit = new RaycastHit();
    29.             if (Physics.Raycast(ray,out hit, 1000))
    30.             {
    31.                 Debug.DrawLine(cpos, hit.point);
    32.                 // cache oneSpawn object in spawnPt, if not cached yet
    33.  
    34.                 GameObject projectile = Instantiate(shotPrefab, new Vector3(cpos.x, cpos.y, cpos.z+1f), Quaternion.identity);
    35.                 // turn the projectile to hit.point
    36.                 projectile.transform.LookAt(hit.point);
    37.                 // accelerate it
    38.                 projectile.GetComponent<Rigidbody>().velocity = projectile.transform.forward * 50;
    39.             }
    40. #endif
    41.         }
    42.     }
    43.  
    44.  
    This looks like the cause of my problem. I was not expecting it to be intentional.
    What is the proper build flag for the unity linux variant? What's the proper way to activate this for a linux build?
    Thanks again,
    Gary
     
  4. huno92

    huno92

    Joined:
    Oct 20, 2015
    Posts:
    14
    If I were you I'd comment out the android/ios part for now and remove all compiler directives and try if it works or not. Just make a backup. Besides 90% of the code is repeated so.. I'd wrap only the if statement or create a flag im doing it like this its easier to debug

    Code (CSharp):
    1.    
    2. private bool android = false;
    3.  
    4.  
    5. #if UNITY_ANDROID
    6.     private void Start()
    7.     {
    8.         android = true;
    9.     }
    10. #endif
    11.  
    12.     void Update()
    13.     {
    14.         if (!android && Input.GetMouseButton(0) || android && Input.touchCount >= 2)
    15.         {
    16.             transform.RotateAround(player.position, Vector3.up, -Input.GetAxis("Mouse X") * speed);
    17.             X = transform.rotation.eulerAngles.x;
    18.             Y = transform.rotation.eulerAngles.y;
    19.             transform.rotation = Quaternion.Euler(X, Y, 0);
    20.         }
    21.     }
    you can probably adapt this code to suit your needs
     
  5. gloriajw

    gloriajw

    Joined:
    Mar 1, 2018
    Posts:
    6
    Thanks for refactoring tips. I will take care of inefficiencies later.

    Can you please answer the question: What are the specific LINUX build precompile directives that I can use going forward, here or elsewhere in code? Is there a UNITY_LINUX precompile directive?

    Thanks,
    Gary
     
  6. gloriajw

    gloriajw

    Joined:
    Mar 1, 2018
    Posts:
    6
    Thanks for the Transform calls as well. This looks interesting, and I'll test with this during refactor.
    Gary
     
  7. huno92

    huno92

    Joined:
    Oct 20, 2015
    Posts:
    14
    I guess in your case you don't need a specific directive just simple #else would be enough, I don't know if there is one.. Btw my code is like a total work in progress these calls are probably random stuff from stackoverflow or unity forums, I got the "rotateAround" call from the official docs tho.
     
  8. gloriajw

    gloriajw

    Joined:
    Mar 1, 2018
    Posts:
    6
    I tested #else, it did not solve the problem.
    Thanks anyway.
    Gary
     
  9. Tak

    Tak

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    I believe that touch input is not supported in the Linux player.
    I think this may be coming (at least mouse emulation for touch input) in Unity 2018.2.
     
  10. gloriajw

    gloriajw

    Joined:
    Mar 1, 2018
    Posts:
    6
    Thank you!
    Gary
     
    Last edited: Apr 9, 2018
  11. ahuska

    ahuska

    Joined:
    Feb 7, 2018
    Posts:
    3
    I wrote this in another related thread, copying it here for maximum coverage:

    It looks like Unity 2018.2 fixed something related to touch "Linux: Fix Linux touch input for mouse events (947049)" at https://unity3d.com/unity/beta/unity2018.2.0b2

    I'm very curious if multi-touch works yet because I've been holding off on buying a multi-touch monitor for a project until it does.
     
  12. dilmerval

    dilmerval

    Joined:
    Jun 15, 2013
    Posts:
    232
    I am using Unity 2018.3.0 with a eGalaxTouch in Linux and just like the original request stated I can’t seem to be able to get touch events in the build that is running in Ubuntu. Did I miss anything ?
     
  13. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    Touch was implemented and broken again and will be fixed again in a future version.
     
  14. janlarwig

    janlarwig

    Joined:
    Dec 15, 2018
    Posts:
    1
    @Schubkraft What is the current status of touch support in Linux?
    Similar to dilmer, we use a eGalaxTouch display with Linux (Linux Mint 17). We would like to port our software from Unity 5.5.0 to Unity 2018.3 but can't do so at the moment because dragging does not work at all with the touch display. We do not actually need touch events but instead we would like the touch display to behave exactly the same as a mouse. However, as stated before dragging (press & hold) does not properly work.
     
  15. erengokgur

    erengokgur

    Joined:
    Oct 8, 2018
    Posts:
    1
    I am also suffering from the same issue. Pressed (default button script) works, however touch (as click) is not working properly though. Surprisingly, while I am moving the mouse and touching on the screen at the same time, touch (as clicks) event works.
     
  16. jerome-lacoste

    jerome-lacoste

    Joined:
    Jan 7, 2012
    Posts:
    206
    It seems we are suffering from the same issue. Our (2017.4 LTS) apps are broken on Linux on Latitude 3340 with ELAN touchscreen, I suspect because of the above.

    I've tested that the trackpad and the touch behave differently WRT to X11 events using xev, and while clicks work, any kind of dragging doesn't. This seems very similar to @erengokgur' s description.

    Is there a version of Unity that works?

    Thanks
     
  17. AelkamDev

    AelkamDev

    Joined:
    Dec 19, 2016
    Posts:
    1
    I'm also suffering from this problem, the company i work for sells touch screen tables for kids with educational games that currently uses windows 8 iot, we want to change the OS to linux but most of our partners are developing games with unity 2018.3+, will this be fixed in unity 2019.3 or is it an 2020+ issue for unity?

    Thanks!
     
  18. jerome-lacoste

    jerome-lacoste

    Joined:
    Jan 7, 2012
    Posts:
    206
  19. jerome-lacoste

    jerome-lacoste

    Joined:
    Jan 7, 2012
    Posts:
    206
  20. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    Hey again, I looked into where this got stuck. We unplugged the pipe and it is now moving forward again. Will keep you updated as to when it will happen. Sorry (yet again) for the delay.
     
    DxballPlus likes this.
  21. jerome-lacoste

    jerome-lacoste

    Joined:
    Jan 7, 2012
    Posts:
    206
  22. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    The fix landed for 2017.4.33. So hopefully this fixes all your use cases too. Let me know if it doesn't after the release.
    Sorry again for this taking too long :(
     
    ys00-1 likes this.
  23. shoroiusagi

    shoroiusagi

    Joined:
    Nov 24, 2019
    Posts:
    2
    I am trying to get touch working with my Wacom Cintiq pro 16 graphics tablet on Manjaro Linux (with the latest libwacom driver), however
    Input.touchSupported
    is always
    false
    .

    Mutlitouch works perfectly in Krita, so it's probably a Unity bug (maybe not interpreting X11 touch events properly)

    Any help would be much appreciated as it is blocking future features in our app.
    Thanks!
     
  24. Thomas_Kole_YIPP

    Thomas_Kole_YIPP

    Joined:
    Jan 7, 2019
    Posts:
    5
    Proper touch screen support is still not working in 2020.1.10f1.
    It does something, but it has about a one second delay, and only a single touch works, and swiping is broken.
    This has been tested on Ubuntu 18.04 and 20.04 with various touch screens.

    https://issuetracker.unity3d.com/issues/linux-standalone-player-not-receiving-touch-events

    This issue is closed, but should be open.

    Worth noting that (multi)touch works in the desktop environment and other applications.
     
  25. zammle2009wtf

    zammle2009wtf

    Joined:
    May 30, 2018
    Posts:
    5

    My unity project is in 2020.1.10f1.
    Version Ubuntu 20.04.1 LTS.

    Touch is very unresponsive.
    Sliders are completely broken!
    Has there been a fix yet?