1.发布部署出来的链接放到手机上测试。
ios:20秒读条然后闪退;vivo:9秒读条闪退;小米:15秒进入
然鹅,资料只有130kb的图片。

2.报这个警告,修改Build文件夹里的UnityLoader.js取消
移动端展示弹出提示框,点击OK后继续打开webgl
please note the unity webgl is not currently supported on mobiles.press ok if you wish to continue anyway.
请注意,手机目前不支持unity webgl。如果仍要继续,请按ok。
修改UnityLoader.js:

compatibilityCheck:function(e,t,r){UnityLoader.SystemInfo.hasWebGL?UnityLoader.SystemInfo.mobile?t():["Firefox","Chrome","Safari"].indexOf(UnityLoader.SystemInfo.browser)==-1?t():t():e.popup("Your browser does not support WebGL",[{text:"OK",callback:r}])},Blobs:{},loa...(省略)


3.自适应屏幕修改和手机端强制横屏index.html
因为浏览器的分辨率不一样,所以我上面的button都不在原位置,而且分辨率小的浏览器显示的画布都不全,就得做自适应。
还有PC端是横版的,要是手机端是竖版的就得做两套UI,判断webgl是运行在PC端还是手机端,然后jslib本地插件从浏览器获取屏幕分辨率数据再把数据传回unity再通过screen.Resolution()函数设置画布的大小有点麻烦,我们直接就手机端强制横屏了。(测试最新判断unitywebgl运行在PC还是手机端的方法报了五个错打出来的空包,老办法PC是cube 手机端是sphere还是可以的)

<!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 | TestConnection</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 gameInstance = UnityLoader.instantiate("gameContainer", "Build/num3.json", {onProgress: UnityProgress});function ChangeCanvas(){document.getElementById("gameContainer").style.width = window.innerWidth + "px";document.getElementById("gameContainer").style.height = window.innerHeight + "px";document.getElementById("#canvas").style.width = window.innerWidth + "px";document.getElementById("#canvas").style.height = window.innerHeight + "px";}</script></head><body onResize="ChangeCanvas()"><div class="webgl-content"><div id="gameContainer" style="width: 100%; height: 100%"></div></div><style type="text/css">@media screen and (orientation: portrait) { /*竖屏*/.webgl-content {position:absolute; width: 100vh; height: 100vw; top: 0; left: 100vw; -webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -ms-transform: rotate(90deg); transform: rotate(90deg); transform-origin: 0% 0%; } }@media screen and (orientation: landscape) {html{width : 100vw;height : 100vh;}body{width : 100vw;height : 100vh;}.webgl-content{width : 100vw;height : 100vh;}}</style></body>
</html>
.webgl-content * {border: 0; margin: 0; padding: 0}/*添加 width: 100%; height: 100%;*/
.webgl-content {position: absolute; top: 50%; left: 50%; width: 100%; height: 100%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}.webgl-content .logo, .progress {position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
.webgl-content .logo {background: url('progressLogo.Light.png') no-repeat center / contain; width: 154px; height: 130px;}
.webgl-content .progress {height: 18px; width: 141px; margin-top: 90px;}
.webgl-content .progress .empty {background: url('progressEmpty.Light.png') no-repeat right / cover; float: right; width: 100%; height: 100%; display: inline-block;}
.webgl-content .progress .full {background: url('progressFull.Light.png') no-repeat left / cover; float: left; width: 0%; height: 100%; display: inline-block;}.webgl-content .logo.Dark {background-image: url('progressLogo.Dark.png');}
.webgl-content .progress.Dark .empty {background-image: url('progressEmpty.Dark.png');}
.webgl-content .progress.Dark .full {background-image: url('progressFull.Dark.png');}/*如果你要保存 footer模块, 然后又要让footer显示在最顶部,这样处理*/
.webgl-content .footer {margin-top: -45px; margin-left: 5px; margin-right: 5px; z-index: 1; position: relative; height: 38px; line-height: 38px; font-family: Helvetica, Verdana, Arial, sans-serif; font-size: 18px;}
.webgl-content .footer .webgl-logo, .title, .fullscreen {height: 100%; display: inline-block; background: transparent center no-repeat;}
.webgl-content .footer .webgl-logo {background-image: url('webgl-logo.png'); width: 204px; float: left;}
.webgl-content .footer .title {margin-right: 10px; float: right;}
.webgl-content .footer .fullscreen {background-image: url('fullscreen.png'); width: 38px; float: right;}

4.logo替换成gif进度加载的样式、背景图替换

.webgl-content * {border: 0; margin: 0; padding: 0}
.webgl-content {position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}.webgl-content .logo, .progress {position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
.webgl-content .logo {background: url('person.gif') no-repeat center / contain; width: 154px; height: 130px;}
.webgl-content .progress {height: 18px; width: 141px; margin-top: 90px;}
.webgl-content .progress .empty {background: url('progressEmpty.Light.png') no-repeat right / cover; float: right; width: 100%; height: 100%; display: inline-block;}
.webgl-content .progress .full {background: url('progressFull.Light.png') no-repeat left / cover; float: left; width: 0%; height: 100%; display: inline-block;}.webgl-content .logo.Dark {background-image: url('person.gif');}
.webgl-content .progress.Dark .empty {background-image: url('progressEmpty.Dark.png');}
.webgl-content .progress.Dark .full {background-image: url('progressFull.Dark.png');}.webgl-content .footer {margin-top: 5px; height: 38px; line-height: 38px; font-family: Helvetica, Verdana, Arial, sans-serif; font-size: 18px;}
.webgl-content .footer .webgl-logo, .title, .fullscreen {height: 100%; display: inline-block; background: transparent center no-repeat;}
.webgl-content .footer .webgl-logo {background-image: url('webgl-logo.png'); width: 204px; float: left;}
.webgl-content .footer .title {margin-right: 10px; float: right;}
.webgl-content .footer .fullscreen {background-image: url('fullscreen.png'); width: 38px; float: right;}


背景图在webgl.json里改,再替换unityloader.js

{"companyName": "DefaultCompany",
"productName": "HidedenObject",
"productVersion": "1.0",
"dataUrl": "webgl.data.unityweb",
"wasmCodeUrl": "webgl.wasm.code.unityweb",
"wasmFrameworkUrl": "webgl.wasm.framework.unityweb",
"graphicsAPI": ["WebGL 2.0","WebGL 1.0"],
"webglContextAttributes": {"preserveDrawingBuffer": false},
"splashScreenStyle": "Dark",
"backgroundUrl":"bg.jpg",
//"backgroundColor": "#231F20",
"cacheControl": {"default": "must-revalidate"},
"developmentBuild": false,
"multithreading": false,
"unityVersion": "2019.4.35f1c1"
}

【unity发布webgl】遇到的问题和解决办法相关推荐

  1. Unity发布WebGL注意事项以及移动端打开webgl网页

    Unity发布WebGL网页端 Unity发布webGL项目时存在很多的易错点,这些错误点没有统一的规律,因为是跨平台开发,开发过程中需要去解决未知的和已知的报错点,下面就我这两年开发WebGL遇到的 ...

  2. unity发布webgl 触摸控制和鼠标控制冲突问题解决

    unity发布webgl 触摸控制和鼠标控制冲突问题解决 参考文章: (1)unity发布webgl 触摸控制和鼠标控制冲突问题解决 (2)https://www.cnblogs.com/pz904/ ...

  3. Unity发布WebGL时如何修改默认的载入进度条sf?

    Unity发布WebGL版本后,需要去除Unity的Logo,首先关闭Splash Image去除Made with Unity启动画面(在File->Build Settings->Pl ...

  4. Unity发布WebGL不显示中文字体问题

    在Unity发布WebGL的时候中文不能够显示,主要在于字体的设置,Unity默认的字体是Arial字体 首先想到的是字体类型不对,接下来更换字体 解决方案: 1.在Asset下创建文件夹,Font ...

  5. 分享一个unity发布webgl 的复制粘贴功能的插件,unity打包webgl的坑

    unity发布webgl 难免需要复制粘贴功能,而自带的UGUI的InputField是不具备的 所以一直在寻找可用的方案,但是unity webgl相关的资料比较少,找下来记录一下,希望可以帮助大家 ...

  6. unity发布webgl本地搭建服务器

    当我们使用Unity发布WebGL项目的时候直接运行是不允许的,如下图提示: 如果我们没有线上服务器,怎么办?我们可以使用Windows的IIS服务,操作系统:Windows 10企业版G. Unit ...

  7. Unity使用VS编辑器打开项目失败解决办法

    Unity使用VS编辑器打开项目失败解决办法 解决过程 解决过程 具体表现为:项目文件.sln无法打开,打开脚本文件后无法关联到Unity编辑器 报错信息可能不同,参考出错表现即可 首先去清除有逻辑错 ...

  8. Unity发布WebGL运行问题

    写在前面 Unity发布到Web平台的项目,在低版本的浏览器中,直接右键本地打开index.html文件,便可打开项目运行,但是升级浏览器后,发现在双击打开项目时,显示网页不支持运行WebGL等错误. ...

  9. unity 发布webGL坑点二: 不显示中文字体

    原因: WebGL无权限读取本地操作系统的字体文件 方案: 多语言,字体文件打bundle, 把字体文件打进包再发布 中文字体不能用Unity原生字体,需要自己导入字体 免费商用字体: www.hel ...

  10. Unity发布WebGl注意事项

    unity 版本是5.5,不过看了2017的文档好像也是差不多,绝大部分都是根据官方文档,希望有帮助,如果有错误或者你知道更多这方面的只是,请告知下,大恩言谢. 1:对webgl发布的工程文件说明 在 ...

最新文章

  1. 干货 | MTCNN实时人脸检测网络详解与代码演示
  2. android游戏开发者大会,第二届中国Android应用开发大会将开
  3. Ping Tracert result Command explanation
  4. 《LeetCode力扣练习》第14题 C语言版 (做出来就行,别问我效率。。。。)
  5. 异常处理程序和软件异常——Windows核心编程学习手札之二十四
  6. FPGA在各行业的应用分析
  7. toc](boost::type_erasure::is_subconcept相关的测试程序
  8. 210224阶段三信号量、互斥锁
  9. java 对线程进行事务控制_Java 多线程事务回滚 ——多线程插入数据库时事务控制...
  10. createdroptargets_使用DUILIB建立项目
  11. htmlspecialchars() 函数过滤XSS的问题
  12. Linux CentOS 查看服务器信息命令及其它常用命令
  13. RabbitMQ学习之集群模式
  14. 计算机语言9月排行榜,TIOBE 9月编程语言排行榜发布,C+增速最快
  15. Leetcode每日一题:36.valid-sudoku(有效的数独)
  16. 会议管理SaaS平台Social Tables融资1300万美元
  17. Linux下的时间戳
  18. python的字符串类型本质上是一种字符序列_20170402Python变量类型 知识点梳理
  19. PHP 遍历文件夹及文件类及处理类
  20. 什么是商业数据分析师?

热门文章

  1. PHP将图片剪切成圆形
  2. 用户细分概念辨析——用户分群与用户分层
  3. 「ZEALER 出品」Shawn Talk 第三期 iOS 7 的「槽点」跟观点
  4. 海外博士申请经历分享
  5. 夕夕博士的视频观后笔记集合~
  6. 项目实战--Ego微商小程序
  7. 郭盛华年收入5000万是真的吗?
  8. onenote 导出为 html,Exporting or convert OneNote 2010 to HTML, not MHTML
  9. java声音提取_如何在Android中使用java从mp4中提取音频到mp...
  10. Gstreamer- 协商(Negotiation)