Unity WebGL 取消浏览器警告

1.浏览器支持

https://docs.unity3d.com/Manual/webgl-browsercompatibility.html

 

2.可用方案

 using System;
 using System.IO;
 using System.Text.RegularExpressions;
 using UnityEditor;
 using UnityEditor.Callbacks;
 
 public class PostBuildActions {
     [PostProcessBuild]
     public static void OnPostProcessBuild(BuildTarget target, string targetPath) {
         var path = Path.Combine(targetPath, "Build/UnityLoader.js");
         var text = File.ReadAllText(path);
         text = Regex.Replace(text, @"compatibilityCheck:function\(e,t,r\)\{.+,Blobs:\{\},loadCode",
             "compatibilityCheck:function(e,t,r){t()},Blobs:{},loadCode");
         File.WriteAllText(path, text);
     }
 }


Unity打包完毕后,修改UnityLoader.js文件,进行文本替换。

注:

1. Unity Release模式导出有效,Debug模式文本内容不一致(可自行修改正则代码)

2. WebGL我使用的是Unity 2017.1版本 ,高版本暂时没测试有效性。

 

相关警告提示:

Your browser does not support WebGL
Please note that Unity WebGL is not currently supported on mobiles. Press OK if you wish to continue anyway.
Please note that your browser is not currently supported for this Unity WebGL content. Press OK if you wish to continue anyway.
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值