使用Unity生成的webgl游戏遇到了问题。 该游戏在Android设备上可以像Facebook即时游戏一样正常运行,但无法在iPhone上加载,并且卡在90%以下的数字上。
这是我的index.html:
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | Helix Jump</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<link rel="stylesheet" href="TemplateData/style.css">
<script src="TemplateData/UnityProgress.js"></script>
<script src="https://connect.facebook.net/en_US/fbinstant.6.1.js"></script>
<script src="Build/UnityLoader.js"></script>
<script>
var gameInstance;
FBInstant.initializeAsync().then(function() {
gameInstance = UnityLoader.instantiate("gameContainer", "Build/facebook-platform.json", {onProgress: UnityProgress});
});
/*var gameInstance = UnityLoader.instantiate("gameContainer", "Build/facebook-platform.json", {onProgress: UnityProgress});*/
</script>
</head>
<body>
<div class="webgl-content">
<div id="gameContainer" style="width: 960px; height: 600px"></div>
<div class="footer">
<div class="webgl-logo"></div>
<div class="fullscreen" onclick="gameInstance.SetFullscreen(1)"></div>
<div class="title">Helix Jump</div>
</div>
</div>
</body>
</html>
这是我的加载脚本:
function UnityProgress(gameInstance, progress) {
if (!gameInstance.Module)
return;
if (!gameInstance.logo) {
gameInstance.logo = document.createElement("div");
gameInstance.logo.className = "logo " + gameInstance.Module.splashScreenStyle;
gameInstance.container.appendChild(gameInstance.logo);
}
if (!gameInstance.progress) {
gameInstance.progress = document.createElement("div");
gameInstance.progress.className = "progress " + gameInstance.Module.splashScreenStyle;
gameInstance.progress.empty = document.createElement("div");
gameInstance.progress.empty.className = "empty";
gameInstance.progress.appendChild(gameInstance.progress.empty);
gameInstance.progress.full = document.createElement("div");
gameInstance.progress.full.className = "full";
gameInstance.progress.appendChild(gameInstance.progress.full);
gameInstance.container.appendChild(gameInstance.progress);
}
gameInstance.progress.full.style.width = (100 * progress) + "%";
gameInstance.progress.empty.style.width = (100 * (1 - progress)) + "%";
FBInstant.setLoadingProgress(progress*100);
if (progress == 1){
FBInstant.startGameAsync()
.then(function() {
console.log('Game Started');
});
}
gameInstance.logo.style.display = gameInstance.progress.style.display = "none";
}
我做错了吗? 感谢您的帮助。