我需要知道浏览器是否阻止了插件,特别是 Unity 网络播放器。在这种情况下,我想告诉用户如何解锁插件。我尝试过,navigator.plugins
但认为它很活跃,所以没用。有谁知道我怎么能得到这个?
谢谢
编辑:unity API 的函数也getUnity
返回我的对象,而不是null
因为对象已经初始化
我需要知道浏览器是否阻止了插件,特别是 Unity 网络播放器。在这种情况下,我想告诉用户如何解锁插件。我尝试过,navigator.plugins
但认为它很活跃,所以没用。有谁知道我怎么能得到这个?
谢谢
编辑:unity API 的函数也getUnity
返回我的对象,而不是null
因为对象已经初始化
你可以这样做:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Unity Web Player | Example</title>
<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
<script type="text/javascript">
if (typeof unityObject != "undefined") {
unityObject.embedUnity("unityPlayer", "Example.unity3d", 600, 450, null, null, unityLoaded);
}
function unityLoaded(result) {
if (result.success) {
var unity = result.ref;
var version = unity.GetUnityVersion("3.x.x");
alert("Unity Web Player loaded!\nId: " + result.id + "\nVersion: " + version);
} else {
alert("Please install Unity Web Player!");
}
}
</script>
</head>
<body>
<!-- This will be replaced by Unity content. -->
<div id="unityPlayer">Unity content can't be played. Make sure you are using compatible browser with JavaScript enabled.</div>
</body>
</html>
您可以使用“从 Unity 网络播放器内容调用网页功能”。从统一调用一个javascript,它将在页面上设置一个变量,页面timeout
脚本将检查变量并在几秒钟后显示消息