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:
    11
    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:
    6,340
    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
  3. jc_crash

    jc_crash

    Joined:
    Jul 30, 2019
    Posts:
    11
    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:
    216
  5. jc_crash

    jc_crash

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