我如何检查webgl是否在移动环境中播放?我在谷歌上做了一些例子,但没有一个能正常工作。我尝试了Input.touchSupported和#if UNITY_IOS || UNITY_ANDROID。有任何想法吗?
好的,我刚刚找到了执行此操作的最佳方法。
http://answers.unity.com/answers/1698985/view.html
它立即起作用。
资产/插件/webgl/MyPlugin.jslib
var MyPlugin = {
IsMobile: function()
{
return UnityLoader.SystemInfo.mobile;
}
};
mergeInto(LibraryManager.library, MyPlugin);
在Unity中
[DllImport("__Internal")]
private static extern bool IsMobile();
public bool isMobile()
{
#if !UNITY_EDITOR && UNITY_WEBGL
return IsMobile();
#endif
return false;
}