mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
修正日志重定向下层日志跳转功能
修正日志重定向下层日志跳转功能
This commit is contained in:
@@ -19,6 +19,21 @@ namespace TEngine.Editor
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// 获取资源路径
|
||||||
|
string assetPath = AssetDatabase.GetAssetPath(instanceID);
|
||||||
|
|
||||||
|
// 判断资源类型
|
||||||
|
if (!assetPath.EndsWith(".cs"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool autoFirstMatch = assetPath.Contains("Logger.cs") ||
|
||||||
|
assetPath.Contains("DefaultLogHelper.cs") ||
|
||||||
|
assetPath.Contains("GameFrameworkLog.cs") ||
|
||||||
|
assetPath.Contains("AssetsLogger.cs") ||
|
||||||
|
assetPath.Contains("Log.cs");
|
||||||
|
|
||||||
var stackTrace = GetStackTrace();
|
var stackTrace = GetStackTrace();
|
||||||
if (!string.IsNullOrEmpty(stackTrace) && (stackTrace.Contains("[Debug]") ||
|
if (!string.IsNullOrEmpty(stackTrace) && (stackTrace.Contains("[Debug]") ||
|
||||||
stackTrace.Contains("[INFO]") ||
|
stackTrace.Contains("[INFO]") ||
|
||||||
@@ -28,6 +43,15 @@ namespace TEngine.Editor
|
|||||||
stackTrace.Contains("[EXCEPTION]")))
|
stackTrace.Contains("[EXCEPTION]")))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
if (!autoFirstMatch)
|
||||||
|
{
|
||||||
|
var fullPath = UnityEngine.Application.dataPath.Substring(0, UnityEngine.Application.dataPath.LastIndexOf("Assets", StringComparison.Ordinal));
|
||||||
|
fullPath = $"{fullPath}{assetPath}";
|
||||||
|
// 跳转到目标代码的特定行
|
||||||
|
InternalEditorUtility.OpenFileAtLineExternal(fullPath.Replace('/', '\\'), line);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 使用正则表达式匹配at的哪个脚本的哪一行
|
// 使用正则表达式匹配at的哪个脚本的哪一行
|
||||||
var matches = Regex.Match(stackTrace, @"\(at (.+)\)",
|
var matches = Regex.Match(stackTrace, @"\(at (.+)\)",
|
||||||
RegexOptions.IgnoreCase);
|
RegexOptions.IgnoreCase);
|
||||||
|
Reference in New Issue
Block a user