yyl
8 天以前 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using UnityEngine;
 
/// <summary>
/// WebGL 环境下直接调用浏览器 console.error,不受 Unity Release Build 日志抑制影响。
/// 非 WebGL 平台回退到 Debug.LogError。
/// </summary>
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
    }
}