Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

WASM Build - Runtime detect mobile or desktop

Discussion in 'Project Tiny' started by newguy123, Nov 30, 2020.

  1. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    On a wasm build, how can I detect if the device is a pc/mac vs a mobile device?

    I know there's this:
    https://docs.unity3d.com/Manual/PlatformDependentCompilation.html

    But since wasm is UNITY_WEBGL, how does that help me determine if the device is mobile or desktop?

    On desktop I want to remove faked UI controls, where of course it must be shown on mobile
     
  2. kevinmv

    kevinmv

    Unity Technologies

    Joined:
    Nov 15, 2018
    Posts:
    51
    Browser detection will need to be done at runtime since a web build can potentially run anywhere. We don't currently expose a library function to look-up the UserAgent for the browser but it is something you can implement in JS and send back to the runtime in the meantime.

    For the JS --> C# interop take a look at the getting started doc https://docs.google.com/document/d/...HfnAX-CpYLK3aOdwA/edit#heading=h.6u7xyqroin5d

    Hope this helps!
     
    newguy123 likes this.