当前位置:网站首页>unity webgl报 Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON
unity webgl报 Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON
2022-08-04 05:56:00 【吴梓穆】
这个问题是json解析出现了问题,可能的情况比较多,但是如果你没有乱改过unity的模板文件,或者使用了自定义的模板类,那么很有可能是因为打包的时候修改了目标文件夹名导致的
问题出在Index.html里
因为我用了自定义的模板,导致这个Json名不会跟随打包的文件夹而变动,但是bulid里的json文件却会跟随打包的文件夹的改变而改变
这很明显会导致找不到json文件,解决方案就是将index.html里的目标Json名修改为正确的名字
如
<!DOCTYPE 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 | MaintenancePlant</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<link rel="stylesheet" href="TemplateData/style.css">
<script src="TemplateData/UnityProgress.js"></script>
<script src="Build/UnityLoader.js"></script>
<script> var unityInstance = UnityLoader.instantiate("unityContainer", "Build/GongChang2.json", {
onProgress: UnityProgress}); var intiUrl = "http://49.235.71.170:8077/system/MonitorCameras/listApi"; function InitGame_My() {
unityInstance.SendMessage("ScriptManager","InitScene",intiUrl); } function OpenOneMonitor(str) {
alert("传入的参数:"+str); } </script>
</head>
<body onResize="ChangeCanvas()">
<div class="webgl-content">
<div id="unityContainer" style="width:100%; height:100%"></div>
</div>
<script type="text/javascript"> function ChangeCanvas() {
document.getElementById("unityContainer").style.width = window.innerWidth + "px"; document.getElementById("unityContainer").style.height = window.innerHeight + "px"; document.getElementById("#canvas").style.width = window.innerWidth + "px"; document.getElementById("#canvas").style.height = window.innerHeight + "px"; } </script>
</body>
</html>
边栏推荐
猜你喜欢
随机推荐
子空间结构保持的多层极限学习机自编码器(ML-SELM-AE)
Unable to preventDefault inside passive event listener due to target being treated as passive. See
curl (7) Failed connect to localhost8080; Connection refused
VMD combined with ISSA to optimize LSSVM power prediction
MySQL大总结
MATLAB 的ICEEMDAN分解代码实现
DOM的12中节点类型,通过关系或方法获取DOM节点,渲染到浏览器页面的一些特效功能,获取DOM节点来改变属性,点击图片,切换为所点击的图片为背景图,页面上的表单验证,点击底部导航栏切换界面
A semi-supervised Laplace skyhawk optimization depth nuclear extreme learning machine for classification
ES6新语法:symbol,map容器
MMDeploy部署实战系列【第二章】:mmdeploy安装及环境搭建
对产品设计,架构设计的一点思考
MySQL重置root密码
Online public account article content to audio file practical gadget
matlab让我的旧手机起死回生
力扣每日一题-第47天-15. 三数之和
Faster RCNN原理及复现代码
MySQL面试题大全(陆续更新)
误差指标分析计算之matlab实现【开源1.0.0版】
Hardware Knowledge: Introduction to RTMP and RTSP Traditional Streaming Protocols
set集合









