- Home /
Detect platform using WebGL build
I'm running unity webgl build on desktop browsers with desktop input settings. Now I need to make the build playable for ipad touch screens as well, and for that I need to detect whether the user is running the webgl app in a touch device browser or on a desktop/laptop browser. I have already used and tested the following code in ipad and desktop but it did not detect the platform properly.
public Text text;
private void Start()
{
if (SystemInfo.deviceType == DeviceType.Handheld)
{
text.text = "You are on a handheld device";
}
else
{
text.text = "You are on a non touch device";
}
}
It was showing "You are on a non touch device" in the touch device as well as in the desktop browser. I have also tried https://answers.unity.com/questions/1698508/detect-mobile-client-in-webgl.html?childToView=1698985#answer-1698985 this solution but it seems that I cannot make it work. I did not have the plugins folder inside of my assets folder so I had to make the folders manually. The version Im running is 2020.3.24f1. Any help would be helpful, thank you.
Your answer
Follow this Question
Related Questions
I ACCIDENTALLY converted my game - HELP! 1 Answer
Objects Relocate 0 Answers
How can I using VideoPlayer in Stadia? 0 Answers
Audio not working through headphones in editor 0 Answers
How do you develop games for multi-platforms in 1 single project 1 Answer