I need to set the UI layout for each of those devices.
Is it possible to detect is a smartphone or mobile when I detect that user can use the touch screen, and how can I detect is it really a PC or pc with a touch screen?
Hi @Dava,
Your best bet is to detect the size of the viewport (width / height) and size your UI accordingly.
For touch input, you can check if it’s available using the following:
if( this.app.touch){
// we have touch input
}
1 Like
How can I see the size of the viewport from the code ?
You can use the width/height reported by the PlayCanvas graphics device:
var width = this.app.graphicsDevice.width;
var height = this.app.graphicsDevice.height;
https://developer.playcanvas.com/en/api/pc.GraphicsDevice.html#width
1 Like