The plugin allows you to check if your Unity WebGL game is running on a PC or mobile device.
on PC | on Mobile |
---|---|
Unity WebGL の実行環境が PC かモバイル端末かを判別するスクリプトを公開しました
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";
}
https://github.com/gigacee/CheckIfMobileForUnityWebGL.git?path=Assets/Plugins/CheckIfMobileForUnityWebGL
Copy Assets/Plugins/CheckIfMobileForUnityWebGL/CheckIfMobileForUnityWebGL.jslib
to your project.
Assets/Plugins/
.