当前位置:网站首页>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>
边栏推荐
- Detailed explanation of DenseNet and Keras reproduction code
- 七夕送礼,心愿直抵!
- Network skills: teach you to install batteries on the router, you can still surf the Internet when the power is cut off!
- ES6新语法:symbol,map容器
- Microsoft computer butler 2.0 beta experience
- 如何用matlab做高精度计算?【第一辑】
- MySQL大总结
- 【C# - 爬虫】使用Selenium实现爬虫,获取近七天天气信息(包含完整代码)
- nacos 返回 403 unknown user 太他么坑了 源码解析
- MAML principle explanation and code implementation
猜你喜欢

在线公众号文章内容转音频文件实用小工具

格拉姆角场GAF将时序数据转换为图像并应用于故障诊断

Hardware Knowledge: Introduction to RTMP and RTSP Traditional Streaming Protocols

西门子PLC1200与fanuc机器人进行profibus通讯

Faster - RCNN principle and repetition code

JVM工具之 JPS

Base64编码原理

unicloud 腾讯云 上传文件 Have no access right to the storage uniapp

网络技巧:教你给路由器装上电池,断电照样可以上网!

SQL去重的三种方法汇总
随机推荐
ES6新语法:symbol,map容器
事件链原理,事件代理,页面的渲染流程,防抖和节流,懒加载和预加载
What is the connection between GRNN, RBF, PNN, KELM?
E-R图总结规范
MySQL内存淘汰策略
力扣每日一题-第47天-15. 三数之和
FCN——语义分割的开山鼻祖(基于tf-Kersa复现代码)
MATLAB 的ICEEMDAN分解代码实现
SQL去重的三种方法汇总
数据库:整理四个实用的SQLServer脚本函数
ResNet详解:ResNet到底在解决什么问题?
IDEA中创建编写JSP
MySQL大总结
Database: Organize Four Practical SQL Server Scripting Functions
水平垂直居中的12种方法,任意插入节点的方法,事件的绑定的三种方法和解绑的方法,事件对象,盒子模型
秒杀系统设计
SQL存储过程详解
nacos 返回 403 unknown user 太他么坑了 源码解析
格拉姆角场GAF将时序数据转换为图像并应用于故障诊断
MMDeploy部署实战系列【第二章】:mmdeploy安装及环境搭建