当前位置:网站首页>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>
边栏推荐
- 90多款matlab工具箱打包放送
- ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
- SQL去重的三种方法汇总
- 代码小变化带来的大不同
- “需求370解决解决爬取章节之后主题讨论评论消失问题”工作总结
- 无监督特征对齐的迁移学习理论框架
- 类图规范总结
- 53个全球免费学术资源数据库整理,查资料写论文必备【开学必备】
- 什么是多态。
- Computer knowledge: desktop computers should choose the brand and assembly, worthy of collection
猜你喜欢
2DCNN, 1DCNN, BP, SVM fault diagnosis and result visualization of matlab
pycharm专业版使用
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
Error occurred while trying to proxy request项目突然起不来了
【深度学习实践(二)】上手手写数字识别
Base64编码原理
MAML principle explanation and code implementation
SENet detailed explanation and Keras reproduction code
fanuc机器人IO分配报警信号分配无效
mysql基础(4)
随机推荐
MySQL(4)
窥探晶体世界的奥秘 —— 230种空间群晶体结构模型全在这里
MMDeploy部署实战系列【第三章】:MMdeploy pytorch模型转换onnx,tensorrt
Faster - RCNN principle and repetition code
网页中常用的两种绘图技术,用canvas绘图,绘制出一个三角形,矩形,柱状图,扇形图
mysql锁机制
Unable to preventDefault inside passive event listener due to target being treated as passive. See
EfficientNet解读:神经网络的复合缩放方法(基于tf-Kersa复现代码)
IDEA中创建编写JSP
MATLAB 的ICEEMDAN分解代码实现
字符串的一些方法
Triton部署mmdeploy导出的TensorRT模型失败篇
ResNet详解:ResNet到底在解决什么问题?
JVM工具之 JPS
FCN——语义分割的开山鼻祖(基于tf-Kersa复现代码)
Provide 和 Inject 的用法
53个全球免费学术资源数据库整理,查资料写论文必备【开学必备】
专属程序员的浪漫七夕
数据库文档生成工具V1.0
Mac安装PHP开发环境