Unity WebGL无法在Chrome上加载

我已经做了一个简单的游戏,但是当我试图加载这个它不加载。

我正在为WebGL(HTML 5)构建。 页面加载时出现这些错误。

Unity版本 – 5.3.1f1 Chrome版本 – 47.0.2526.106米

它在Firefox上工作得很好。

XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.LoadCompressedFile @ UnityLoader.js:1 UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.jsgz. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.DecompressAndLoadFile @ UnityLoader.js:1 UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.mem. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.LoadCompressedFile @ UnityLoader.js:1 UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.memgz. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.DecompressAndLoadFile @ UnityLoader.js:1 UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.data. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.LoadCompressedFile @ UnityLoader.js:1 UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.datagz. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. 

为什么不加载在铬?

我相信这个问题是由于你在本地运行而不是在networking服务器或模拟的networking服务器上发生的。

基本上:你需要在地址栏中说http://或者https://或者其他什么而不是file://

如果你有一个networking服务器,尝试在那里上传。 如果没有,请检查WAMP或XAMPP

我可以推荐WAMP给在“networking服务器仿真”中很less或没有经验的人,但记得要么退出Skype或更改Skype使用的端口,因为WAMP将使用同一个不工作的端口。

尝试在Firefox。

以下是Unity doc中的相关信息:“你可以直接在大多数浏览器中查看你的WebGL播放器,只需打开index.html文件即可。出于安全原因,Chrome对本地文件:URL打开的脚本设置了限制,所以这种技术无法工作。如果你使用Unity的Build&Run命令(菜单:File> Build&Run),那么这个文件将被暂时托管在一个本地Web服务器上,并从本地URL打开(这可以避免安全限制)。 –disable-web-security命令行选项使其能够从file:url加载内容。

https://docs.unity3d.com/Manual/webgl-building.html