Unity发布WebGL后使用手机浏览器打开Touch手指触摸无法响应

unity5.6.5,使用触摸操作对物体进行旋转时

//在浏览器中GetAxis("Mouse X")和GetAxis("Mouse Y")始终为0
Input.GetAxis("Mouse X")
//可以正常使用,和GetAxis的返回值不一样
Input.GetTouch(0).deltaPosition
似乎使用手机浏览器查看的unity webgl只能使用touch的输入,类似Input.GetMouseButton(0),Input.MousePosition都不能用。

网页自适应https://blog.csdn.net/qq_38456478/article/details/78869971

在生成的html里面修改代码
    <script type="text/javascript">
    function Reset() {
 var canvas = document.getElementById("#canvas"); 
canvas.height= document.documentElement.clientHeight;
 canvas.width = document.documentElement.clientWidth; 
console.log(canvas.width );
 } 
    </script>
  </head>
  <body οnlοad="Reset()" οnresize="Reset()">
      <div class="webgl-content"style="width: 100%; height: 100%" >
      <div id="gameContainer" style="width: 100%; height: 100%"></div>
    </div>
  </body>
</html>
来实现网页版随浏览器自适应


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值