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.

猜你喜欢

转载自blog.csdn.net/lile1234_show/article/details/79544818
今日推荐