using UnityEngine; /// /// WebGL 环境下直接调用浏览器 console.error,不受 Unity Release Build 日志抑制影响。 /// 非 WebGL 平台回退到 Debug.LogError。 /// public static class WebGLDebug { public static void LogError(string msg) { #if UNITY_WEBGL && !UNITY_EDITOR string escaped = msg.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\n", "\\n").Replace("\r", ""); Application.ExternalEval("console.error('" + escaped + "')"); #else Debug.LogError(msg); #endif } }