Check if Mobile for Unity WebGL
Detect whether your Unity WebGL game runs on PC or mobile devices using a lightweight .jslib plugin. Enables platform-specific logic and UI adjustments for WebGL builds without editor testing limitations.
com.gigacee.checkifmobileforunitywebgl Unity Compatibility

Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/checkifmobileforunitywebgl.git?path=Assets/Plugins/CheckIfMobileForUnityWebGL README Markdown
Copy this to your project's README.md
## Installation
Add **Check if Mobile for Unity WebGL** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/checkifmobileforunitywebgl.git?path=Assets%2FPlugins%2FCheckIfMobileForUnityWebGL
```
[](https://www.pkglnk.dev/pkg/checkifmobileforunitywebgl)README
Check if Mobile for Unity WebGL
The plugin allows you to check if your Unity WebGL game is running on a PC or mobile device.
| on PC | on Mobile |
|---|---|
![]() |
![]() |
æ„æŹèȘă«ăăèȘŹæ / Explanation in Japanese
Usage
This script uses .jslib plugin. You can check if your Unity WebGL game is running on a PC or mobile device by calling IsMobile() in CheckIfMobileForUnityWebGL.jslib as follows:
#if !UNITY_EDITOR && UNITY_WEBGL
[System.Runtime.InteropServices.DllImport("__Internal")]
private static extern bool IsMobile();
#endif
private void CheckIfMobile()
{
var isMobile = false;
#if !UNITY_EDITOR && UNITY_WEBGL
isMobile = IsMobile();
#endif
GetComponent<Text>().text = isMobile ? "Mobile" : "PC";
}
Installation
Package Manager
https://github.com/gigacee/CheckIfMobileForUnityWebGL.git?path=Assets/Plugins/CheckIfMobileForUnityWebGL
Manual
Copy Assets/Plugins/CheckIfMobileForUnityWebGL/CheckIfMobileForUnityWebGL.jslib to your project.
:warning: Be sure to put it in Assets/Plugins/ .
Comments
No comments yet. Be the first!

Sign in to join the conversation
Sign In