Unity WebGL 取消瀏覽器警告


1.瀏覽器支持

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

2.可用方案

 1  using System;
 2  using System.IO;
 3  using System.Text.RegularExpressions;
 4  using UnityEditor;
 5  using UnityEditor.Callbacks;
 6  
 7  public class PostBuildActions {
 8      [PostProcessBuild]
 9      public static void OnPostProcessBuild(BuildTarget target, string targetPath) {
10          var path = Path.Combine(targetPath, "Build/UnityLoader.js");
11          var text = File.ReadAllText(path);
12          text = Regex.Replace(text, @"compatibilityCheck:function\(e,t,r\)\{.+,Blobs:\{\},loadCode",
13              "compatibilityCheck:function(e,t,r){t()},Blobs:{},loadCode");
14          File.WriteAllText(path, text);
15      }
16  }

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.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM