答案是将UnityLoader.js中的UnityLoader.SystemInfo.mobile和["Edge", "Firefox", "Chrome", "Safari"].indexOf(UnityLoader.SystemInfo.browser) == -1替换成false。
----------------------------------------------------------------------------------------------------------------------------
那如何自动化呢?
那就需要用到PostProcessBuild后处理脚本了,需要放到Editor文件夹内,脚本内容如下:
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)
{
if (target != BuildTarget.WebGL)
return;
var path = Path.Combine(targetPath, "Build/UnityLoader.js");
var text = File.ReadAllText(path);
text = text.Replace("UnityLoader.SystemInfo.mobile", &#