[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
前言:
之前看的很多关于WebGL全屏的代码和帖子,但都是unity2018的版本,目前听说unity2020之后,webgl加载速度有优化,所以没敢换回低版本,索性在这个版本基础上修改,写的不好的地方,请大家指正,下面开始:
一、首先设置:
1、打包之后的html 文件中 < script >中增加Reset方法
(在现有的html文件的< script > 此处 </ script >添加下面的代码即可)
示例图:
代码段:
function Reset() { var canvas = document.getElementById("#canvas"); canvas.
height= document.body.clientHeight; canvas.width = document.body.clientWidth; }
function Reset(){ var canvas = document.getElementById("#canvas"); canvas.height
= document.documentElement.clientHeight; canvas.width = document.documentElement
.clientWidth; }
2、在Html文件的 < body >标签增加onload和onresize调用Reset方法
(同样在现有的html文件中,找到<body 此处> 中添加)
示例图:
代码段:
onload="Reset()" onresize="Reset()"
3、style.css设置.
(找到打包webgl的TemplateData文件夹的style.css文件,添加如下代码).
示例图:
代码段:
html,body{width:100%;height:100%;margin:0;padding:0;overflow:hidden;} .webgl-
content{width: 100%; height: 100%;} .unityContainer{width: 100%; height: 100%;}
以上设置之后,会发现手机能够完全全屏,但PC浏览不正常,于是进行下一步。
二、其次关于PC浏览器的设置
找到打包的Html文件,找到以下代码段,复制粘贴即可:
示例图:
代码段
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) { container.
className= "unity-mobile"; config.devicePixelRatio = 1; } else { container.
className= "unity-mobile"; config.devicePixelRatio = 1; }
三、删除以下内容:< div-“unity-footer”> 和 alert(message)
示例图:
四、正常这些已经满足全屏要求了,logo和背景修改很简单:
方式 1:文件夹把素材替换掉
方式 2:修改模板代码
五、进度条还没研究,后面再更新。