From 1e1d1b7d08c86486a52f6b790c5fc947c576d5aa Mon Sep 17 00:00:00 2001 From: AlanWalk <4654826+alanwalk@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:46:43 +0800 Subject: [PATCH] =?UTF-8?q?[unity]console=E6=B7=BB=E5=8A=A0debug=E3=80=81t?= =?UTF-8?q?imeLog=E6=8E=A5=E5=8F=A3=E5=AE=9E=E7=8E=B0=20(#1946)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/upm/Runtime/Resources/puerts/log.mjs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/unity/Assets/core/upm/Runtime/Resources/puerts/log.mjs b/unity/Assets/core/upm/Runtime/Resources/puerts/log.mjs index 7b2bb282d42..9c3580291f8 100644 --- a/unity/Assets/core/upm/Runtime/Resources/puerts/log.mjs +++ b/unity/Assets/core/upm/Runtime/Resources/puerts/log.mjs @@ -63,6 +63,11 @@ if (UnityEngine_Debug || !global.console) { if (console_org) console_org.error.apply(null, Array.prototype.slice.call(arguments)); UnityEngine_Debug.LogError(toString(arguments)); } + + console.debug = function() { + if (console_org) console_org.debug.apply(null, Array.prototype.slice.call(arguments)); + UnityEngine_Debug.Log(toString(arguments)); + } console.trace = function() { if (console_org) console_org.trace.apply(null, Array.prototype.slice.call(arguments)); @@ -83,6 +88,14 @@ if (UnityEngine_Debug || !global.console) { console.time = function(name){ timeRecorder.set(name,+new Date); } + console.timeLog = function(name, ...args){ + const startTime = timeRecorder.get(name); + if(startTime){ + console.log(String(name)+": "+(+new Date - startTime)+" ms", ...args); + }else{ + console.warn("Timer '" + String(name)+ "' does not exist"); + }; + } console.timeEnd = function(name){ const startTime = timeRecorder.get(name); if(startTime){