Search Unity

SystemInfo.deviceType returns incorrect type in WebGL

Discussion in 'Scripting' started by jc_crash, Sep 12, 2019.

  1. jc_crash

    jc_crash

    Joined:
    Jul 30, 2019
    Posts:
    21
    Hi all,

    I'm building a WebGL application and I want to detect which type of device I'm on so I can alter the interaction paradigms accordingly. I started out using Input.touchSupported, but the problem is, if on a laptop, it returns true (I'm guessing because of the touch pad).

    Then I found SystemInfo.deviceType but found that even when the application is running on my Samsung S6, it still returns DeviceType.Desktop.

    Any ideas?

    Thanks!
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You're likely to find lots of broken functionality like this when running WebGL builds on unsupported browsers/devices. See the manual page below.

    https://docs.unity3d.com/Manual/webgl-browsercompatibility.html
    Also:
    https://docs.unity3d.com/Manual/webgl-gettingstarted.html
    Since only desktop browsers are supported, it wouldn't surprise me if WebGL just always responds that it is on a desktop. But no idea if that is the case.
     
    Last edited: Sep 12, 2019
    Bunny83 likes this.
  3. jc_crash

    jc_crash

    Joined:
    Jul 30, 2019
    Posts:
    21
    Thanks for your reply @Joe-Censored,

    I had found that beforehand however had wondered if anybody else had come across the issue. I guess that is most likely the problem though!

    Cheers!
     
  4. doctorpangloss

    doctorpangloss

    Joined:
    Feb 20, 2013
    Posts:
    270
    LazyFox555 and Bunny83 like this.
  5. jc_crash

    jc_crash

    Joined:
    Jul 30, 2019
    Posts:
    21
    Thanks for the answer @doctorpangloss!! That indeed solves the problem! And thanks also for the link to your tips.
     
  6. pandolfini

    pandolfini

    Joined:
    Feb 5, 2020
    Posts:
    17
  7. Arcanebits

    Arcanebits

    Joined:
    Dec 18, 2013
    Posts:
    108
    For anyone looking for it, the answer of @doctorpangloss is still valid in March 02 2023 for Android based phones.
     
  8. romoboss29

    romoboss29

    Joined:
    Aug 11, 2023
    Posts:
    1
    Are you sure? It works on my iPhone...
     
  9. hgeas

    hgeas

    Joined:
    Nov 22, 2022
    Posts:
    1
    it can work on iPhone, but not in Safari though. A friend of mine tested in chrome in his iPhone and it worked