Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

WASM Build - Runtime detect mobile or desktop

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

  1. newguy123


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

    I know there's this:

    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


    Unity Technologies

    Nov 15, 2018
    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

    Hope this helps!
    newguy123 likes this.